Header Nav not being written

Permalink 1 user found helpful
I have the "Header Nav" code in my header.php file for the theme I have created but it is not being written to the page.

I 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

 
thebobajob replied on at Permalink Reply
AAAAAH! Please someone help, it's driving me bonkers and I can't see what I have done wrong.

This is the code I have used in header.php

<?php
$a = new Area('Header Nav');
$a->display($c);
?>


header.php is showing but not the nav - I now have 4 pages!

Thanks
Bob
madeforspace replied on at Permalink Reply
madeforspace
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.
thebobajob replied on at Permalink Reply
Thanks!!

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
madeforspace replied on at Permalink Reply
madeforspace
Hi 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
thebobajob replied on at Permalink Reply
Shucks, I thought you were going to save me!
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
thebobajob replied on at Permalink Reply
I can get a nav by adding an Auto Nav to each page within the Header Nav block but if I add this as a block under the PageTypes ti doesn't show up either. There seems to be a problem with a site-wide navigation being written to the pages.
12345j replied on at Permalink Reply
12345j
hey, take a look at line 13 where it says
<?php echo $this->getThemePath(); ?>/master.js
it should be
<?php echo $this->getThemePath()?>/master.js
just take out the semi colon and it should work fine.
thebobajob replied on at Permalink Reply
Hi, thanks for looking but no joy, still won't appear. It's like it's not recognising the reserved 'Header Nav' handle.
vertex21 replied on at Permalink Reply
has anyone had any luck figuring this out? I think I'm having the same issue, only it works fine for my home page, but for all subsequent pages I create there is no Auto Nav information showing and the code for my inside pages is exactly the same as my default.php page!!
thebobajob replied on at Permalink Reply
I've stil no solution to this, ended up having to put an AutoNav on every page. It's working now but really not how I want it to be, for the clients' sake!
cyandesigns replied on at Permalink Best Answer Reply
Hey 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!
vertex21 replied on at Permalink Reply
Thanks for the tip, cyandesigns... I actually had tried using the scrapbook method before but it didn't work for me.. come to find out I had given the block the wrong name. if you look at the scrapbook it says the name of the scrapbook item, but that isn't necessarily the name of the scrapbook block to call.. I clicked on view and it gave me "Auto-Nav: 'Main Nav 76'" whereas when I just look at the scrapbook it says just "Main Nav". I put the "Main Nav 76" in the code instead of "Main Nav" and it worked beautifully!! thank you so much.. :)

Mike
thebobajob replied on at Permalink Reply
SMASHING! That has worked a treat, thank you! and thanks to vertext21 for the extra tip. At last a solution!

Bob
chapter5 replied on at Permalink Reply
Hi there,

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 :)
Agetis replied on at Permalink Reply
Agetis
This solution helped me just partly!
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!