[SOLVED] Page alias wildcard in conditional statement in template?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
neuroboy
Forum Members
Forum Members
Posts: 13
Joined: Sun Dec 02, 2007 4:10 am

[SOLVED] Page alias wildcard in conditional statement in template?

Post by neuroboy »

Hi,

I need a bit of help formatting a conditional statement in a template. This query refers to FrontEndUsers and CustomContent, but the actual thing I need help with is about smarty and/or CMSMS.

Basically my site is composed of 5 or 6 sections, which I've set up nicely with tabs using a modified NCleanBlue template. Each section/tab will have its own slightly modified template for slightly different styling (eg. banner graphics, colours etc.).

One of the sections (lets call it 'Stuff') has a sub-section for registered users, which will display custom content once they've logged in via FrontEndUsers.

Now rather than have yet another seperate template just for this sub-section, I thought I could just put a smarty conditional statement in the template as follows:

Code: Select all

{if $page_alias == "stuffmembers"} 
   {if $ccuser->loggedin()}
      {content}
   {else}
      <p>You need to be registered and signed in to see this content.</p>
   {/if}
{else}
   {content}
{/if}
This works fine for the one page with the alias "stuffmembers", but I will want to setup several pages for members. Rather than set this conditional statement up to explicitly reference the page alias of each page (thereby necessitating having to update the template each time a new Stuff Members page is added), I thought I could do this by setting up each page with an alias that starts "stuffmembers-", and then amend the first line of the code to read:

Code: Select all

{if $page_alias == "stuffmembers-*"}
But that wildcard '*' doesn't work as I thought.

Can anybody be so kind as to suggest a way I can do this (probably very basic) thing, as I can't find any info elsewhere?

Many thanks,
Mark.
Last edited by neuroboy on Mon Jan 25, 2010 2:04 pm, edited 1 time in total.
neuroboy
Forum Members
Forum Members
Posts: 13
Joined: Sun Dec 02, 2007 4:10 am

Re: Page alias wildcard in conditional statement in template?

Post by neuroboy »

Ok, nevermind, I used a bit of PHP instead :)

Code: Select all


{if substr_count($page_alias, "smartmembers")}

Last edited by neuroboy on Mon Jan 25, 2010 4:18 pm, edited 1 time in total.
Post Reply

Return to “Modules/Add-Ons”