PDA


View Full Version : Conditional Module


MoB Dudditz MD
05-27-2007, 06:04 PM
~I meant to post this in v3.0~

UPDATED: see bottom
I was attempting to create a single module to interact with various pages.
My pages are set up as different games and I was wanting a review / image module to display for each game.
For instance,
pages are:
Halo
Gears of War
World of Warcraft

My idea is instead of creating a module per page, is creating a single module
with some sort of conditionals within the template to display infoormation depending on what page the user was viewing.

if page is Halo, display Halo image,info and game review.
if page is Gears, display Gears image,info and game review.
if page is Warcraft, display Warcraft image,info and review.

Is there a way to provide a conditional based on the $pages[title] ??

TY
::::::::::::
update
I completed a working module from a conditional to the title.(which must be exact).
However, I am not sure this is the best way to pull this off.
Here is what I came up with:

<if condition="$pages['title'] == 'Page One'">
display information relevant to page one
</if>
<if condition="$pages['title'] == 'Page Two'">
display information relevant to page two
</if>
<if condition="$pages['title'] == 'Page Three'">
display information relevant to page three
</if>


This allows you to have a single information module.

Brian
05-28-2007, 11:29 AM
You probably want to remove the ] bracket from the end of your <if condition>'s.
Other than that... What exactly was your question?

MoB Dudditz MD
05-29-2007, 08:29 AM
I was wanting a dynamic module of content dependant on which page the user was viewing.
The only way I know of doing it is with the $pages[title]
Is there a way to create a conditinal off the pageid ?

And is the proper way:
$pages[title] // without single quotes ?
$pages['title'] // with single quotes ?
when used in a template condition

Brian
05-29-2007, 11:19 AM
You could use $pages['pageid'] or $pages['name'] (for the identifier). Technically you should use the single quotes.

convergent
05-30-2007, 12:46 AM
I think I did what you are wanting to do, but I'm using a combination of GARS and CMPS to accomplish it. Take a look at these two pages....

http://pdaphonehome.com/?page=ppcpe
http://pdaphonehome.com/?page=7135

The first block is pulling a single thread that is in a GARS forum and all that stuff... specs, images, and even all the links to the other parts of the site are all custom fields in GARS that are entered when the thread/article is created. So I drop that block on each page and then I have a parameter for the thread ID that I add in the CMPS AdminCP to point it to the thread/article where it finds all the other stuff. Not sure if this is what you were looking for... if so, you'd need GARS to pull it off.

What I am actually trying to do is take it a step further and just create one page for all the different stuff... and pass in a separate parameter along with the page name... because I have a ton of pages that are basically all the same except for the parameter that points to the GARS article. If you figure out how to do that, let me know.