Custom variables

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
mattots

Custom variables

Post by mattots »

Hi,

I'm new to the forum. I've just started using CMSMS so no doubt I'll have a few questions over the coming weeks and months!

What I would like to be able to do is assign custom variables to specific pages. For example, I want to highlight a particular menu item when you're on any of the sub-pages within that section of the site. Of course, I can do this by putting some php in my template that checks the alias of all the pages in the section and sets a css class, eg.

Code: Select all

if ($alias == 'about-us' || $alias == 'contact-us' || $alias == 'recruitment' etc.etc.etc.) {
echo 'class="highlight"';
}
But it would be much neater to just say:

Code: Select all

if ($custom_variable == 'bob') {
echo 'class="highlight"';
}
Is there any way of doing this, or something similar? Potentially there could be a need to assign several custom variables to a page - other uses would be to pull in page-specific stylesheets or scripts, etc.

Sorry if I'm being thick and there's already a way to do this!

Matt
sn3p
Forum Members
Forum Members
Posts: 169
Joined: Mon Oct 15, 2007 2:27 pm

Re: Custom variables

Post by sn3p »

If you want to display user dependant content check out the FrontEndUsers and CustomContent modules.
I'm not sure if this is what you want, but hope it helps.
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Custom variables

Post by kermit »

for the first thing, highlighting current or active (parent) pages; look at the menu templates that are installed with the sample content.. an extra class is already added to menu items that are the currently active page or an active parent page (when one of its child pages is active), which you can use to style those items differently via css.

for the second thing, page-specific content.. you can use $page_alias within a template to test for current page alias: {if $page_alias eq 'my-special-page'}{/if}

for page-specific css or scripts; simply include those in that page's metadata; if used on more than one page, then put the reused code in a global content block and refer to that instead in the metadata. remember, if code has curly-braces (like scripts and css), wrap the code around {literal} .... {/literal} tags so smarty (the template engine) won't try to interpret it.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Locked

Return to “CMSMS Core”