[solved] Different image for each template

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
paull19
New Member
New Member
Posts: 3
Joined: Sat Jan 19, 2008 2:33 pm

[solved] Different image for each template

Post 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,
Last edited by paull19 on Tue Jan 22, 2008 8:06 am, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Different image for each template

Post 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
Last edited by RonnyK on Sat Jan 19, 2008 3:19 pm, edited 1 time in total.
paull19
New Member
New Member
Posts: 3
Joined: Sat Jan 19, 2008 2:33 pm

Re: Different image for each template

Post 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!
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Different image for each template

Post 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
agdemack

Re: [solved] Different image for each template

Post 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
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: [solved] Different image for each template

Post 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
agdemack

Re: [solved] Different image for each template

Post 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?
Last edited by agdemack on Tue Jan 29, 2008 12:56 am, edited 1 time in total.
Post Reply

Return to “CMSMS Core”