Page 1 of 1

Random logo images in my header code

Posted: Fri Jul 08, 2011 10:33 am
by Andrew Prior
I want to have a randomised header image (logo) on my website, http://onemansweb.org, and also have that image hyperlinked back to the home page. I have the images working (code from Calguy) but cannot get a working link.

My code works in a plain html file.
I've run it in a dummy file which has no spreadsheets and templates attached.
I can also run it in the body of a page on my website, where the image is randomly dispayed, and the link works:

It will not run in my website when it is placed in a template header.

Code: Select all

{capture assign='headnum'}{1|rand:20}{/capture}
<h1>
  <a href="http://onemansweb.org"><img src="uploads/images/headers/header_{$headnum}.jpg" alt="Australia" title="Australia" /></a>
</h1>

I can run the code without issues if I leave out the hyperlink:

Code: Select all

{capture assign='headnum'}{1|rand:20}{/capture}
<h1>
  <img src="uploads/images/headers/header_{$headnum}.jpg" alt="Australia" title="Australia" />
</h1>
I can only assume I have conflict with something else.If I include the hyperlink, I get the hyperlink working in the page header, but no picture.
Can anyone spot where the conflict occurs? My coding skills are limited.

Many thanks,
Andrew Prior

To clarify: I get a random logo, I have no hyperlink to home.

The code below is from a LAMP installation of CMS Made Simpleā„¢ 1.9.4.1 "Faanui"

The original template and stylesheet code is stock CMS since about 1.4, I think.


This is the original template code

Code: Select all

<div id="header">
  <h1>{cms_selflink dir="start" text="$sitename"}</h1>
  <hr class="accessibility" />
</div>
This is the original stylesheet code
div#header {
height: 201px; /* adjust according your image size */
background: #385C72;
}

div#header h1 a {
/ you can set your own image here */

background: #385C72 url(uploads/images/headers/header_02.jpg) no-repeat 0 1px; */
display: block;
height: 201px; /* adjust according your image size */
text-indent: -999em; /* this hides the text */
text-decoration:none; /* old firefox would have shown underline for the link, this explicitly hides it */
}
I now have this in the template:
<div id="header">
{* Random Headers follow *}
{capture assign='headnum'}{1|rand:20}{/capture}
<h1>
<img src="uploads/images/headers/header_{$headnum}.jpg" alt="Australia" title="Australia" />
</h1>
<hr class="accessibility" />
</div>
I now have this stylesheet
div#header {
height: 201px; /* adjust according your image size */
background: #385C72;
}

div#header h1 a {


}

Re: Random logo images in my header code

Posted: Fri Sep 16, 2011 3:12 pm
by andriesinfoserv
{cms_selflink dir="start"} is the old smarty tag for the link to home page. try that and img src without the a href inside the <h1> and see if that works