Page 1 of 1

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

Posted: Sat Sep 16, 2006 11:28 am
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?

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

Posted: Sat Sep 16, 2006 4:32 pm
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

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

Posted: Sat Sep 16, 2006 5:22 pm
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?

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

Posted: Sun Sep 17, 2006 4:15 pm
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

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

Posted: Sun Sep 17, 2006 4:19 pm
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.

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

Posted: Sun Sep 17, 2006 5:23 pm
by haapati
Sounds great, but I can't get it to work.  ???