How get a same image on the Page 1 and all the Page's 1 subpages?

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
haapati
Forum Members
Forum Members
Posts: 20
Joined: Sun Sep 10, 2006 4:14 pm

How get a same image on the Page 1 and all the Page's 1 subpages?

Post by haapati »

My page hierarchy
-----------------------
Page 1
  • Subpage 1
  • Subpage 2
  • Subpage 3
Page 2
  • Subpage 1
  • Subpage 2
  • Subpage 3
-----------------------

How do I get the image1.jpg on the Page 1 and all the Page's 1 subpages, and the image2.jpg on the Page 2 and the Page's 2 all subpages?

I don't want to write a huge ifelse code where I put all the page's and subpage's names.

Code: Select all

global $gCms;
$thispage = '';
$thispage = $gCms->variables['page_name'];

if ($thispage == the_name_of_one_of_your_pages)  
echo "something_you'd_like_written_to_this_page";

elseif  ($thispage == the_name_of_another_one_of_your_pages) 
echo "something_else_you'd_like_written_to_this_page";

else 
echo "something_you'd_like_written_as_your_default";
Is there something easier way?
Pierre M.

Re: How get a same image on the Page 1 and all the Page's 1 subpages?

Post by Pierre M. »

I would say it is very easy or I don't understand your question.

Make one template for main page 1 with image1.jpg and one template for main page 2 with image2.jpg.
Then just add mainpage1, subpage1.1, subpage1.2... using template 1.
and mainpage2, subpage2.1, subpage2.2... using template 2.

You should not need to write code, just use the templating features.

PM
haapati
Forum Members
Forum Members
Posts: 20
Joined: Sun Sep 10, 2006 4:14 pm

Re: How get a same image on the Page 1 and all the Page's 1 subpages?

Post by haapati »

I know that should do the trick, but i'm looking for some user added tags to do this. Then I just put the usertag in to the template code. I think it's much easier for the editors, than always remember to choose the right template.

Is there a some kind of variable which tell's what main page you are (page 1 or page 2)?. Even if you are in page's 1 or page's 2 subpage?

Code: Select all

$gCms->variables['page_name'];
That variable tell's what is the page name, but does any variable tell the thing what we are looking for?
Pierre M.

Re: How get a same image on the Page 1 and all the Page's 1 subpages?

Post by Pierre M. »

haapati wrote: I think it's much easier for the editors, than always remember to choose the right template.
If they don't want to remember to choose the template, may be they can clic on "preview" before "submit" to see afterwards if they should choose another template ?

But I agree content producers (writers) could be a role and content assembling (in templates) could be another. Let's wait for 1.1 with workflow and multiversion to see role separation.

PM
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: How get a same image on the Page 1 and all the Page's 1 subpages?

Post by calguy1000 »

See this thread: http://forum.cmsmadesimple.org/index.ph ... 914.0.html

It describes a user defined tag that will get the page alias of the root parent, and place it in a smarty variable.
Once you have the smarty variable you could use this name to build an image filename, and then use the
{image src=$imagename} tag in your template.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
haapati
Forum Members
Forum Members
Posts: 20
Joined: Sun Sep 10, 2006 4:14 pm

Re: How get a same image on the Page 1 and all the Page's 1 subpages?

Post by haapati »

Sounds great, but I can't get it to work.  ???
Post Reply

Return to “Tips and Tricks”