Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

How to link the header to hompage?


Reply

7 Posts   1734 Views

Avatar
Sunnybex

14 November 2009 at 3:34am Community Member, 39 Posts

Hi everyone,

I would like to have a link from the header of my page (same for all subpages & home) to the HomePage. The header contains only a picture and no text. How can I do this?

Thanks for your comments

Bex

Avatar
Willr

14 November 2009 at 12:54pm (Last edited: 14 November 2009 12:54pm), Forum Moderator, 5511 Posts

Well if its an image tag in the template you can just wrap it in a <a> tag.

Your current html might be something like -

<img src="MyHeader.jpg" alt="Header Image" />

To link it to the home page you change it to

<a href="home/"><img src="MyHeader.jpg" alt="Header Image" /></a>

Avatar
Sunnybex

17 November 2009 at 12:53am Community Member, 39 Posts

not really...

the image is in the layout.css file:
#logo{
...
background: url(../images/picture.jpg) no repeat left top;}

and I changed the page.ss file
<div id="logo">
<img src="picture.jpg" alt="Header Image" />
</div>

But it is not working, what did I miss? (yes, I did the flush-thing...)

Avatar
banal

17 November 2009 at 1:45am (Last edited: 17 November 2009 1:48am), Community Member, 901 Posts

Why do you specify a background via CSS and put an image in the logo div?
You can easily wrap the <img> in <a> Tags as willr pointed out.. you can even style the <a> tag to look and behave exactly like the <div> element there:

<a id="logo" href="$BaseHref">
<img src="picture.jpg" alt="Header Image" />
</a>

Then in CSS you have to change the #logo element from inline to block

#logo {
....
display: block;
}

Avatar
Sunnybex

17 November 2009 at 2:56am Community Member, 39 Posts

that was how the template "highway" was build, but I guess in the end it is because I am no ssspecialist but an enduser...

Avatar
banal

17 November 2009 at 4:09am Community Member, 901 Posts

It doesn't really matter if you're a SilverStripe specialist or not. These are simple html/css issues. If you know CSS and HTML, you should be able to edit/modify the SilverStripe templates, since they are basically just HTML documents mixed with some special template markup.
At least adding the logo and a link to the homepage should not require any deep knowledge of SilverStripe or PHP.

Avatar
Sunnybex

5 January 2010 at 4:11am Community Member, 39 Posts

ok, after some trials and buying the book I finally got it. Not nice but running at least:

page.ss:
<div id="header">
         <a id="logo" href="http://www.mywonderfullsite.com/">
         </a>
...
</div>

header.ss:
<div id="Header"
   
   <a> id="logo" href"$BaseHref">
   <img src="url(../images/picture.png" alt "Header Image" />
   </a>
   
</div>

layout.css:
...
   background: url(../images/picture.png) no-repeat left top;
   display: block;
...

Thank you fo the help & all the best
Bex