Page 1 of 1

Display Text based upon Current page

Posted: Mon Nov 24, 2008 10:06 pm
by 360true
On a new site I have a background image as the header for my inside pages, with a slogan and page title in floating divs over the image.

I am looking for a specific way to determine the level one page and then dictate the slogan and page title.

Example:

Image

This is currently hard-coded:  http://69.13.130.134/index.php?page=about-us where the level 1 nav is About Us, the slogan is Watching puppies get born never gets old.

The background image is http://69.13.130.134/uploads/images/banner_bg.png

The current code is:
      /* Where background image is banner_bg.png) */
     About Us  /* would like this to be dynamic */
      Watching puppies get born never gets old. /* would like this to be dynamic */
   

Now, on page http://69.13.130.134/index.php?page=class-schedule - the level one nav is ADMISSIONS, the current page is class-schedule. I would like the header to read Admissions and the Slogan to be "Blah Blah Blah".

I could do this with a separate CSS for each page, or by putting an individual snippet on each page, but that would be difficult for the end-user client to continue in the future as they have very limited skills.

I am a noob with Smarty so I would appreciate a clean solution, not simply a reference to a .

Thoughts?

Thanks.
360true

Re: Display Text based upon Current page

Posted: Tue Nov 25, 2008 12:00 am
by Zoorlat
Hi there,

First, install the module CGSimpleSmarty.

Then you can get the title of the parent page by using this code:

Code: Select all

{$cgsimple->get_root_alias('','root_alias')}{$cgsimple->get_page_title($root_alias)}
The different slogans are perhaps best to put in global content-blocks.
Then you can do something like:

Code: Select all

{if $root_alias eq "about-us"}
   {global_content name="about-us"}
{elseif $root_alias eq "get-involved"}
      {global_content name="get-involved"}

etc...

{/if}
Then all you need to do is create Global content boxes with the exact names you assigned above.

So, using your own code example:

Code: Select all

    <div id="banner">  /* Where background image is banner_bg.png) */
     <h3>{$cgsimple->get_root_alias('','root_alias')}{$cgsimple->get_page_title($root_alias)}</h3>  
      <div>
         {if $root_alias eq "about-us"}{global_content name="about-us"}
         {elseif $root_alias eq "get-involved"}{global_content name="get-involved"}
         {elseif $root_alias eq "admissions"}{global_content name="admissions"}
         {elseif $root_alias eq "graduate-services"}{global_content name="graduate-services"}
         {elseif $root_alias eq "news-information"}{global_content name="news-information"}
         {elseif $root_alias eq "contact-us"}{global_content name="contact-us"}
         {/if}
      </div>
    </div>
Good luck!
/Z

[solved] Display Text based upon Current page

Posted: Tue Nov 25, 2008 1:08 am
by 360true
Worked like a charm! Thanks!