Page 1 of 1

[solved] Different image for each template

Posted: Sat Jan 19, 2008 2:42 pm
by paull19
Different image for each template

I have been using cms made simple for simple jobs all do now I have a question. I have a site and none of the pages is the same.

There is one image that changes every page.

What is the best way to solve this problem?

- make a unlimited supply of templates?
- make a unlimited supply of css styles?

Is there a easy way to include an image to a page? The image itself does not need to be changed over the year.

Kind regrards,

Re: Different image for each template

Posted: Sat Jan 19, 2008 3:16 pm
by RonnyK
Paul,

If you want a rotating image per page-click you could use some image_rotator tag.

If you want a fixed image per page, you could use some logic, that pulls the image with the same name as the page_alias.

In the template you can call the image, where you use the variable $page_alias, to get the image with the name of that page.

Code: Select all

<img src="uploads/image_{$page_alias}.jpg" />
should work... where you could insert extra parameters like width/height if you want to.

This would pull an image with the name of that page inside, when available.....

Ronny

Re: Different image for each template

Posted: Sat Jan 19, 2008 3:54 pm
by paull19
RonnyK wrote: If you want a fixed image per page, you could use some logic, that pulls the image with the same name as the page_alias.

In the template you can call the image, where you use the variable $page_alias, to get the image with the name of that page.

Code: Select all

<img src="uploads/image_{$page_alias}.jpg" />
Easy as that! Thanks the solution provided helps me out!

Re: Different image for each template

Posted: Sat Jan 19, 2008 6:57 pm
by RonnyK
If it is solved, will you mark the original subject-line to say it is [solved]....

The image_ prefix is offcourse a sample, you can do what you want, the only point I was making was the use of a variable $page_alias in the naming of the file....

Ronny

Re: [solved] Different image for each template

Posted: Fri Jan 25, 2008 12:50 am
by agdemack
I'm needing something very similar, but I want to use the template name within a template.

What is the correct variable for the name of the current template?

{$template}??

thanks

Andrew

Re: [solved] Different image for each template

Posted: Fri Jan 25, 2008 10:32 am
by RonnyK
Andrew,

what is the point in making the image relate to the variable of the template, as a template is connected to the page, if the template has a fixed image, that one is allways pulled.....
If you connect an image to the header of the template, using the stylesheet, that image is allways pulled when a page is called.... I dont see the use in using a variable....

Ronny

Re: [solved] Different image for each template

Posted: Mon Jan 28, 2008 11:42 pm
by agdemack
Sorry, I didn't explain myself well enough.

My need is not for a variable which calls the page name, but for a variable which calls the template name. Its not about images in this case, but CSS.

I have a site with four main sections. Each section will have a template. The Body tag in the template HTML uses the name of the section as the CSS id selector because that's how we identify the section as "active". So it would be good (not vital, but nice) to be able to use a variable for that id selector.

If there's another way to do this which I have yet to discover, I would also be keen to hear it.

thanks
Andrew

[EDIT]:  Reading elsewhere in this forum, I've decided for the moment to have the page alias of the root page of each section use the same name as the template. Then I can use {$cgsimple->get_root_alias()} as the variable for the Body tag ID.

This seems to me to be slightly more complicated than it needs to be?