Header image
Permalink
Concrete5 version 5.5.1
I have added a background image to the sitewide site name block.
On the home page this displays as expected. I have created a new page. When editing the page, the header shows fine. If I navigate to the page through clicking the nav bar, the header does not show. If I edit the page, the header shows and it also shows when I return to the website. If I navigate away, then it doesn't show when I go back. Using Firebug, I can see that the url is being set correctly, but the image is not being found.
I can only assume that Concrete5 is changing the base for relative urls?
Any help gratefully received.
Neil
I have added a background image to the sitewide site name block.
<img title="Stratton House" src="images/SHHeader.png" alt="Stratton House Header" width="960" height="100" />
On the home page this displays as expected. I have created a new page. When editing the page, the header shows fine. If I navigate to the page through clicking the nav bar, the header does not show. If I edit the page, the header shows and it also shows when I return to the website. If I navigate away, then it doesn't show when I go back. Using Firebug, I can see that the url is being set correctly, but the image is not being found.
I can only assume that Concrete5 is changing the base for relative urls?
Any help gratefully received.
Neil
Hostco
Thanks for the reply, but that just ends up in a loop. I am operating in a folder off the main domain, and it is adding the folder name to the url.
i.e. the address bar shows:
Thanks anyway
Neil
Thanks for the reply, but that just ends up in a loop. I am operating in a folder off the main domain, and it is adding the folder name to the url.
i.e. the address bar shows:
http://www.maindomain/foldername/foldername/foldername/...
Thanks anyway
Neil
If I change the img src to be absolute, not relative, then it displays ok. That'll have to be the workaround, but it doesn't seem right ... would be good to understand why the relative addressing isn't working correctly.
Neil
Neil
So this is just a hard-coded <img> tag, not the image block (or any other block)?
The reason you cannot use relative paths is because relative paths are relative to the URL of the page being viewed, not relative to the location of the file on the server. When you use normal HTML pages, these are usually the same thing, but in most CMS's (including concrete5), they are different -- because the "pretty url's" show a different URL than the actual location of your theme files.
The standard way to include images in your theme is to put the images inside the theme directory, then use this:
...to get the absolute path. For example:
The reason you cannot use relative paths is because relative paths are relative to the URL of the page being viewed, not relative to the location of the file on the server. When you use normal HTML pages, these are usually the same thing, but in most CMS's (including concrete5), they are different -- because the "pretty url's" show a different URL than the actual location of your theme files.
The standard way to include images in your theme is to put the images inside the theme directory, then use this:
<?php echo $this->getThemePath(); ?>
...to get the absolute path. For example:
<img src="<?php echo $this->getThemePath(); ?>/images/coolpic.jpg" alt="whatever" />
That's very helpful. I've just gone back to check and I've found that the img src has changed (I don't know how I did it, if it was me) to .
Is this equivalent to your php code?
Many thanks
Neil
{CCM:BASE_URL}/images/header.png
Is this equivalent to your php code?
Many thanks
Neil
The code you pasted is what C5 uses for its "content" blocks. Where are you seeing this exactly? Are you looking in the database? Or in the "view source" of your browser? Or in a php file? Or somewhere else?
Apologies - I am new to C5.
I am seeing this code when I edit the page and then edit the image block. It is in the sitewide site name block.
Neil
I am seeing this code when I edit the page and then edit the image block. It is in the sitewide site name block.
<img title="Stratton House" src="{CCM:BASE_URL}/images/SHHeader.png" alt="Stratton House Header" width="960" height="100" />
Neil
No need to apologize, just trying to understand your problem so I can give you a solution.
Unfortunately I'm still not 100% sure I undersand... when you say that you see that "when you edit the image block", I am confused because when I edit an image block I see some buttons for choosing an image and for setting width and height... I do not see any place in there where code for an <img> tag would appear.
Can you maybe explain to me the exact steps you're taking to see what you're seeing (for example, "I click the 'Edit Page' button, then I click on the block and choose 'Edit Block', then..." etc. etc.?
Or if you could take a screenshot of what you're looking at that would help a lot too I think.
Unfortunately I'm still not 100% sure I undersand... when you say that you see that "when you edit the image block", I am confused because when I edit an image block I see some buttons for choosing an image and for setting width and height... I do not see any place in there where code for an <img> tag would appear.
Can you maybe explain to me the exact steps you're taking to see what you're seeing (for example, "I click the 'Edit Page' button, then I click on the block and choose 'Edit Block', then..." etc. etc.?
Or if you could take a screenshot of what you're looking at that would help a lot too I think.
The image is in an HTML block - which may be why I had the original problem? I have attached three screen dumps showing the route after clicking the edit page button.
Many thanks
Neil
Many thanks
Neil
Okay, I see. So that's the "Content" block, not the "Image" block (I know the terminology is confusing at first, because you can put images into the content block -- I don't mean to be so pedantic but it helps explain the situation in this case).
So... the {CCM:BASE_URL} code is an internal Concrete5 thing -- it should replace that with the actual path to your site when the page is viewed. You do not want to mess with that in the "HTML Source" view of the content editor. What I would do is start over -- delete that image from your content editor, then insert it again (by using the "Insert Image" link in the blue bar at the top of the content editor, not the smaller icon lower down). Don't go into the "HTML Source" thing, just save the block. See if that lets the image show up.
If not, then it's probably the problem with the "define('BASE_URL'..." thing in your config file as @Hostco mentions above.
So... the {CCM:BASE_URL} code is an internal Concrete5 thing -- it should replace that with the actual path to your site when the page is viewed. You do not want to mess with that in the "HTML Source" view of the content editor. What I would do is start over -- delete that image from your content editor, then insert it again (by using the "Insert Image" link in the blue bar at the top of the content editor, not the smaller icon lower down). Don't go into the "HTML Source" thing, just save the block. See if that lets the image show up.
If not, then it's probably the problem with the "define('BASE_URL'..." thing in your config file as @Hostco mentions above.
Many thanks for your help.
Neil
Neil
Define the base url in /config/site.php by adding this line of code to it and saving the file.
swap out the name domainname with your domain name.