Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Jan Filas
Using Velocity to distinguish Homepage
January 17, 2011 4:57 AM
Answer

Jan Filas

Rank: New Member

Posts: 2

Join Date: September 23, 2010

Recent Posts

Hello,

I would like to ask, if there's a way to distinguish homepage (in portal_normal.vm file) using Velocity template system.

To be specific, i need a piece of code injected into portal_normal.vm, which should appear everywhere, but the homepage.

Thank you for any ideas or helps.

Cheers,
Jan
Abhishek Saxena
RE: Using Velocity to distinguish Homepage
January 17, 2011 7:48 AM
Answer

Abhishek Saxena

Rank: Regular Member

Posts: 130

Join Date: June 17, 2009

Recent Posts

A quick workaround
use a check for you homepage in vm file by using

$page it gives you the current page/layout object

==> check if JanHomepage ==$page
<the part you want to show>

not a clean approach just a quick workaround ;)
Jan Filas
RE: Using Velocity to distinguish Homepage
January 17, 2011 8:59 AM
Answer

Jan Filas

Rank: New Member

Posts: 2

Join Date: September 23, 2010

Recent Posts

Hi Abhishek,

thank you for your help.

Unfortunately, it doesn't seem to work as expected, although i dont have clue, why.

i can acces the $page.name variable, which prints Home(as expected).

But when i try to use an IF condition as written below:

#if ($page.name != "Home")
< some of my code, which should be shown on everypage, but homepage >
#end

,the condition doesn't seem to work.

If you have any other suggestions(or my code is wrong), please let me know.

Thank you,
Jan
Abhishek Saxena
RE: Using Velocity to distinguish Homepage
January 20, 2011 10:19 AM
Answer

Abhishek Saxena

Rank: Regular Member

Posts: 130

Join Date: June 17, 2009

Recent Posts

Hi Jan ,

you got it right ,it will work . if its not giving correct condition refer link velocity reference

else set value in a variable and then execute your condition
Wes Kempa
RE: Using Velocity to distinguish Homepage
February 8, 2012 12:41 PM
Answer

Wes Kempa

Rank: New Member

Posts: 1

Join Date: October 4, 2011

Recent Posts

Using $page.name will not work because it will return XML node containing the page name. This is difficult to test against in velocity.

I would suggest using $layout.getName($locale) instead to the localized string value of the page name.