Correct way of referencing template pictures

About the template and stylesheet - and changing the menu
Post Reply
michaelsidenius
Posts: 12
Joined: Mon Sep 07, 2009 3:24 pm

Correct way of referencing template pictures

Post by michaelsidenius » Thu Mar 20, 2014 7:26 pm

Hi,

Is

Code: Select all

"<?php echo $pth['folder']['templateimages']?>myimagename.png"
always the right way to refer to template pictures in both the HTML and CSS file for a template? Or is there a dedicated call for this?

Best regards,

Michael

cmb
Posts: 14227
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Correct way of referencing template pictures

Post by cmb » Thu Mar 20, 2014 8:15 pm

Hi Michael,

this is usually the right way to refer to template images from template.htm, which, despites its file extension, actually is a PHP file. This code will not work in the content (which is plain HTML + CMSimple scripting) or in any CSS file, for instance. To reference such images from the template's stylesheet, simply use the relative path, e.g.:

Code: Select all

url(./images/myimagename.png)
michaelsidenius wrote:Or is there a dedicated call for this?
No (not yet at least).

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

michaelsidenius
Posts: 12
Joined: Mon Sep 07, 2009 3:24 pm

Re: Correct way of referencing template pictures

Post by michaelsidenius » Fri Mar 21, 2014 9:58 am

Hi Christoph,

Thank you for your answer. So if I want to create as "correct" a template as possible according to all new standards, I guess that specifying the images for elements will be best done in the CSS stylesheet file with the url('/images/myimage') command, rather than setting it in the HTM (AKA: PHP) template file?

This should then ease reuse and updating of the template setup.

Best regards,

Michael Sidenius

cmb
Posts: 14227
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Correct way of referencing template pictures

Post by cmb » Fri Mar 21, 2014 11:22 am

Hi Michael,
michaelsidenius wrote:So if I want to create as "correct" a template as possible according to all new standards, I guess that specifying the images for elements will be best done in the CSS stylesheet file with the url('/images/myimage') command, rather than setting it in the HTM (AKA: PHP) template file?
That the depends on the purpose of the images, IMHO. If they are background images, i.e. images that serve only design purposes, it might be best to define them in the CSS; if they are part of the information the website conveys, such as a logo, it might be best to put them in the template. Just consider what a visitors sees, if he has no CSS support (e.g. screenreaders and bots).

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply