Forums de discussion
Add specific class on page
Erick Borges, modifié il y a 10 années.
Add specific class on page
Junior Member Publications: 29 Date d'inscription: 18/12/12 Publications récentes
Is there a way to add a specific class for each page in liferay? This class will stand in the body tag, for example.
Amos Fong, modifié il y a 10 années.
RE: Add specific class on page
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Hi Erick,
You probably need to do some work in theme here. The body tag is usually in portal_normal.vm so you just need to modify that to pull the CSS class from where you want it defined.
You probably need to do some work in theme here. The body tag is usually in portal_normal.vm so you just need to modify that to pull the CSS class from where you want it defined.
Erick Borges, modifié il y a 10 années.
RE: Add specific class on page
Junior Member Publications: 29 Date d'inscription: 18/12/12 Publications récentes
Thank you Amos.
I've found a way to identify the page through page url or the page title. Then I created a condition that adds a class updating the variable "$css_class".
Doing this in portal_normal.vm:
First option, page url:
#if ($theme_display.getURLCurrent().contains("/home") == true)
#set ($css_class = $css_class + " home")
#end
Second option, page title, in case the url doesn't show whatever you want:
#if ($the_title.contains("Home") == true)
#set ($css_class = $css_class + " home")
#end
$theme_display.getURLCurrent() - gets part of url (/web/your-site/your-page);
$the_title - gets page title;
$css_class - just all classes applied on the page.
I've found a way to identify the page through page url or the page title. Then I created a condition that adds a class updating the variable "$css_class".
Doing this in portal_normal.vm:
First option, page url:
#if ($theme_display.getURLCurrent().contains("/home") == true)
#set ($css_class = $css_class + " home")
#end
Second option, page title, in case the url doesn't show whatever you want:
#if ($the_title.contains("Home") == true)
#set ($css_class = $css_class + " home")
#end
$theme_display.getURLCurrent() - gets part of url (/web/your-site/your-page);
$the_title - gets page title;
$css_class - just all classes applied on the page.
Thiago Dantas Martins, modifié il y a 9 années.
RE: Add specific class on page
New Member Publications: 4 Date d'inscription: 27/07/10 Publications récentesErick Borges:
Second option, page title, in case the url doesn't show whatever you want:
#if ($the_title.contains("Home") == true)
#set ($css_class = $css_class + " home")
#end
That second option is just what I need, but in Portuguese we have Page Titles with accents. At the portal I'm working now, the first page's title is "Início", and that piece of code doesn't work for titles with accents like in this case.
I have tried this:
#if ($the_title.contains("Início") == true)
#set ($css_class = $css_class + " inicio")
#end
And also this:
#if ($the_title.contains("Início") == true)
#set ($css_class = $css_class + " inicio")
#end
But without any success.
Can anybody help me with this particular issue?
(I'm a designer.)