Header Nav not being written
Permalink 1 user found helpfulI have three pages in my site including the Home page and the "Add To Header Nav" shows when I am in Edit mode. I can't click on this and when looking at in in Firbug there is no content in it.
Any ideas what I am doing wrong?
Cheers
Bob
The code looks ok, can you copy all the code in your header.php to this post. Also is the header in a folder called 'elements' in your theme?
Sorry if this is obvious stuff but I am just trying to see where it may have gone wrong.
The code for header.php is below. The theme is in root/themes/cakes and is working
header.php is in /elements along with footer.php and both are pulling in.
I have 2 templates, default.php and full.php and they seem to be working
I must be doing something wrong but I'm totally blind to it.
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- Site Header Content //--> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getStyleSheet('master.css')?>" /> <link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getStyleSheet('typography.css')?>" /> <?php Loader::element('header_required'); ?> <!--[if lte IE 6]> <script src="/concrete/js/unitpngfix.js" type="text/javascript"></script> <![endif]--> <script type="text/javascript" src="<?php echo $this->getThemePath(); ?>/master.js"></script> </head> <body>
Bob
To be honest I can't see anything wrong with the code you are using. I am hoping that wiser heads may read this post and come up with something.
My only idea is to change the way you add the Nav to the page. Instead of an editable area maybe embed it in the header, see the link below for a How To
http://www.concrete5.org/documentation/how-tos/developers/hardcode-...
or
Maybe try adding the Header Nav to a scrapbook and call it using:
<?php
$b = Block::getByName('Header Nav');
if( is_object($b) ) $b->display();
?>
I know that neither suggestion fixes your problem but hopefully it gives you an alternative.
Hope that helps
Alex
Thanks for looking into it and I'll try the code you linked to. I may try a re-install first jsut to see if something has corrupted.
Your help is appreciated
Thanks
Bob
The best way I found for adding a navigation that's going to be on every page is to do madeforspace's second suggestion by adding the code to call the block from your scrapbook (or any other scrapbook you may have). I found that by creating a general scrapbook for just "site elements" like header and footer blocks makes it easy to find/edit them later.
Once you put the code in the div you want it to appear in the header
<?php $b = Block::getByName('Header Nav'); if( is_object($b) ) $b->display(); ?>
add the block to your scrapbook and make sure to change the name (c5 will automatically assign it a block number) to whatever is placed in the parenthesis above (ie: Header Nav). It MUST match exactly for this to work.
Hope this helps!
Mike
Bob
This happens to me all the time. This is how I fix it...
(Assuming you're in Edit Mode) > *click* on the "Add to Header nav" then *click* "Add Block" and then *click* on "Auto nav" then *click* the "Add" button.
Now you have a normal (ugly looking) nav.
*click* on the newly added nav (the "Auto Nav" you have just added) and when the little menu pops up *click* on the last link "Custom Template" - select "Header nav" from the select box and *click* the "Update" button. Done :)
This way I could add a block to all my sites but I couldn't edit it! :/
So the better solution is maybe even more simple:
1. Go to Dashboard -> Scrapbook and make a new Scrapbook.
2. On your site now go to the block you want to copy to every page.
3. In edit mode select the block and copy to Scrapbook, In the drop-down menu choose your new Scrapbook you created. Now two options appear:
- New copy to Scrapbook
- Alias original to Scrapbook
Choose the second one: Alias!
4. Now go to another page on your site, where you also want to have this block, select Past from Scrapbook and choose your block.
Do this for every page you want your block to appear.
5. That's it! Since your block are now connected all your changes in this block appear across the entire site :)
Hope I could help somebody.
Live consciously!
This is the code I have used in header.php
header.php is showing but not the nav - I now have 4 pages!
Thanks
Bob