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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to link the header to hompage?


Go to End


7 Posts   2531 Views

Avatar
Sunnybex

Community Member, 39 Posts

14 November 2009 at 3:34am

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

Forum Moderator, 5523 Posts

14 November 2009 at 12:54pm

Edited: 14/11/2009 12:54pm

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

Community Member, 39 Posts

17 November 2009 at 12:53am

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
bummzack

Community Member, 904 Posts

17 November 2009 at 1:45am

Edited: 17/11/2009 1:48am

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

Community Member, 39 Posts

17 November 2009 at 2:56am

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
bummzack

Community Member, 904 Posts

17 November 2009 at 4:09am

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

Community Member, 39 Posts

5 January 2010 at 4:11am

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