Autonav doesn't display on view.php

Permalink
Hi
I've never had to use view.php pages before but I've tried adding the autonav to it, but it doesn't display in the same way - all the styling has gone.

Any ideas why?

Thanks

 
Steevb replied on at Permalink Reply
Steevb
Is the view.php in your theme?

Is the view.php header calling your CSS?

Take a look at the source it should show CSS sheet and path.
lou28 replied on at Permalink Reply
Yes view.php is in my theme and all the other styles on the page are appearing correctly.

It's just the autonav which obviously is inserted separately.

Looking at the code it looks like the appropriate ids and classes aren't being inserted onto the <li>s.

Is there any reason why this might be happening?

Thanks
Steevb replied on at Permalink Reply
Steevb
Could be a CSS thing then?

If you look at the classes and what they called this could help with the styling in your CSS.
lou28 replied on at Permalink Reply
It can't be that as the autonav styles work perfectly on all other pages. It's just view.php for some reason...
beebs93 replied on at Permalink Reply
beebs93
I'm reading your question as if you're making a copy of the autonav's view.php file, but you can't get it display properly on your site.

If that's the case, then the view.php has to be in a sub-folder called "templates" of the autonav block itself (not your /theme folder) like so:

DOCUMENT_ROOT/blocks/autonav/templates/my_autonav/view.php

Where "my_autonav" is the name you wish give your new template. Or, you could simply do:

DOCUMENT_ROOT/blocks/autonav/templates/my_autonav.php

Which works the same - either way is acceptable. Then when you add a new autonav block you can simply choose "Custom Template" and select your custom one.
lou28 replied on at Permalink Reply
Thanks for your replies. I think maybe I didn't explain properly.

Basically this is the view.php file located in the site's theme directory which is used for things like 404 etc, not the view.php used in the autonav folder.

As I said, the autonav feature is working perfectly on all pages apart from the ones which use the view.php template.

Any ideas?

Thanks
Steevb replied on at Permalink Reply
Steevb
Does your view.php look like this?

<?php  
defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header.php'); ?>
<div id="central" class="no-sidebar">
      <div id="body">   
         <?php  
print $innerContent;
         ?>
      </div>
      <div class="spacer">&nbsp;</div>      
   </div>
<?php   $this->inc('elements/footer.php'); ?>
lou28 replied on at Permalink Reply
Yeah, pretty much:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$this->inc('elements/header.php');
?>
    <div id="content">
       <div id="fullwidth">
           <?php
         print $innerContent;
            ?>
        </div>                       
<?php  $this->inc('elements/footer.php'); ?>
lou28 replied on at Permalink Reply
Interestingly, the password input isn't picking up any styles either...

http://www.countrysidenurseries.co.uk/nurseries/parents-room/...
Steevb replied on at Permalink Reply
Steevb
So what CSS is the header calling?
Steevb replied on at Permalink Reply
Steevb
Make sure header is calling both CSS and in your case the nav javascript.


<link href="/themes/nurseries/nav.css" rel="stylesheet" type="text/css" />



Why is your link showing:
http://www.countrysidenurseries.co.uk/index.php/passwordrequest/?re...

Thats not pretty, if you see what I mean

Steev
lou28 replied on at Permalink Reply
I've compared the references to the stylesheets in this password page and in a normal page such as the home page:http://www.countrysidenurseries.co.uk/...

...and they're identical. So everything is being referenced correctly.

The differences are how the autonav is working though. This is how it should look in code:

<div id="nav">
   <ul class="nav">
<li id="homeactive" class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" href="/"></a></li>
<li id="about" ><a href="/about/"></a><ul>
<li id="working-partnership" ><a href="/about/working-partnership/">Giving You Peace of Mind</a></li>
<li id="structure-sessions" ><a href="/about/structure-sessions/">Parents As Partners</a></li>
<li id="tax-credits" ><a href="/about/tax-credits/">Our Rooms</a></li>
<li id="childcare-vouchers" ><a href="/about/childcare-vouchers/">Head Office Support</a></li>
<li id="testimonials" ><a href="/about/testimonials/">Testimonials</a></li>
...etc
    </div>


But this is how it looks in this view.php template page:
<div id="nav">
   <ul class="nav"><li><a href="/"  >Home</a></li>
<li><a href="/about/"  >Countryside Nurseries - About us</a></li>
<li><a href="/nurseries/"  >Our Nurseries</a></li><li><a href="/financials/"  >Financials</a></li>
<li><a href="/links/"  >Links</a></li>
<li><a href="/contact/"  >Contact us</a></li>
</ul>
    </div>


As you can see it looks like the appropriate ids / classes aren't being pulled in for whatever reason.

Any ideas why this might be?
Steevb replied on at Permalink Reply
Steevb
But is your header calling your CSS file?
lou28 replied on at Permalink Reply
Yes it is.
beebs93 replied on at Permalink Reply
beebs93
I don't think this is a CSS problem - if you manually add the IDs via Firebug the link displays properly. As you mentioned, everything is being referenced as it should.

Could you paste the contents of your autonav's view.php (or whichever template you're using)?
lou28 replied on at Permalink Reply
Sure, here you are:
<?
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $aBlocks = $controller->generateNav();
   $c = Page::getCurrentPage();
   $containsPages = false;
   $nh = Loader::helper('navigation');
   //this will create an array of parent cIDs 
   $inspectC=$c;
   $selectedPathCIDs=array( $inspectC->getCollectionID() );
   $parentCIDnotZero=true;   
   while($parentCIDnotZero){
      $cParentID=$inspectC->cParentID;
      if(!intval($cParentID)){
         $parentCIDnotZero=false;
      }else{
beebs93 replied on at Permalink Reply
beebs93
If it was a matter of not being able to load the ctHandle of each page in the nav then we would be seeing something like ...id=""..., but we don't get a blank ID attribute; it's not even firing your autonav template, but it looks like it's firing the default view.

I'm assuming you're using the Page Password addon (http://www.concrete5.org/marketplace/addons/page-password/) given the URL of the example you posted.

If you access said page via the dashboard's site map, go into edit mode and check the block's template what do you see?

I've never used that addon, but perhaps it's programatically adding the block with taking into account the custom view?
lou28 replied on at Permalink Reply
Yes it is the Page Password addon I'm using.

If I do as you suggested, everything looks as it should do really! (doesn't help!)

I'm not quite sure what you mean by your last sentence?
beebs93 replied on at Permalink Reply
beebs93
If it is running your template as intended then if we slightly modify it like so:

} else {
            echo('<li id="'.$_c->getCollectionHandle().'" ><a href="' . $pageLink . '">' . ($thisLevel>0?$ni->getName():"") . '</a>');
            echo '<div style="display:none;">current cPath: ' . $c->cPath . ' current page handle: ' . $c->getCollectionHandle() . '</div>';
         }


..then we should see that hidden <div> in the source. Could you try that and paste the "View Source" code of the autonav? My hunch is that it won't show up since we're not seeing ANY id attribute on the <li> elements at all (not even blank ones).

What I meant by last sentence was that some addons programatically insert a block after content (eg. ProBlog adds a Next/Prev block in this manner after every content block you add). I don't know the Password Page addon so it could be that it's doing so without taking into account the custom template you've built (I'm totally guessing here - a shot in the dark).
lou28 replied on at Permalink Reply
Thanks for all your help on this.
The problem lay in the fact I was adding the autonav in the normal way rather than using the custom template.
I hadn't added the autonav originally so wasn't aware I should be doing it this way, so it was slightly confusing to say the least.

I appreciate all your help.
beebs93 replied on at Permalink Reply
beebs93
Glad you got it worked out :)