Jump to content

Navigation outputting even "hidden" pages


onjegolders
 Share

Recommended Posts

Hi guys, am having a problem with my navigation. For some reason the code I always use and is taken from Ryan's head.inc template is including hidden pages. The pages are also not displaying in the normal tree order.

My code is the following:

<ul id="main_nav" class="span3 hidden-phone">
<?php
$homepage = $pages->get("/"); 
$children = $homepage->children;

foreach($children as $child) {
$class = "";
if ($child === $page->rootParent) {
$class = ' class="active"';
} 
?>

<li class="nav_class_<?php echo ($xyz++%4); ?>"><a href="<?php echo $child->url; ?>"<?php echo $class; ?>><?php echo $child->title; ?></a></li>
<?php }
?>
</ul> <!-- /#main_nav.span3 hidden-phone -->

Strange as this has always worked perfectly on all my other projects. Perhaps it's too late and I'm missing something obvious!

Link to comment
Share on other sites

I've also tested "include=hidden" and additional hidden pages are coming up so I can only assume that PW thinks that the other pages aren't set to be hidden yet in the settings they definitely are.

Is there any other page/template setting that could be overriding this?

Thanks

Is it not something simple like the fact that you're a logged in superuser? Not sure it'll make a difference but try logging out and checking your output.

As far as I'm aware, being logged out doesn't affect the navigation (if it does I'll have to hurriedly go and check all my other sites!)

Link to comment
Share on other sites

You could also try to echo the status of each of your hidden but presented in navigation pages in the loop to check if they are really unpublished in the database.

You could try to do it like this:

if ($child->status & Page::statusHidden) {
echo "I'm hidden!";
} else {
echo "And I'm visible!";
}

Hope it helps.

Edit: You beat me here, Soma. Next time I will write my reply faster :)

Link to comment
Share on other sites

Not sure if slkwrm's code is really right but I guess. Can you also try


if ($child->isHidden()) {
 echo "I'm hidden!";
} else {
 echo "And I'm visible!";
}

Also take a look in mysql "pages" table and look at the "status" field what bit mask it has.

I think there's something else involved we don't see or know here. For example how have you created the site, pages exactly are they imported? If they're marked as hidden in the admin it should really work in frontend. Have you other code in your templates that could cause this? Any special modules installed?

There's nothing wrong with what you're doing at all.

Link to comment
Share on other sites

Not sure if slkwrm's code is really right but I guess. Can you also try


if ($child->isHidden()) {
echo "I'm hidden!";
} else {
echo "And I'm visible!";
}

Also take a look in mysql "pages" table and look at the "status" field what bit mask it has.

I think there's something else involved we don't see or know here. For example how have you created the site, pages exactly are they imported? If they're marked as hidden in the admin it should really work in frontend. Have you other code in your templates that could cause this? Any special modules installed?

There's nothing wrong with what you're doing at all.

I tried that code too thanks Soma and same result.

I have included a screenshot of phpmyadmin as not too sure what I'm looking for.

I don't have any 3rd party modules installed but the data was imported from a localhost version.

I may try adding new pages and seeing what happens?

EDIT: Just tried adding a new page, when I ticked "unpublished" it didn't show up on the site but then when I unchecked "unpublished" it didn't show up either! I'm confused!

post-502-0-74294600-1344510848_thumb.png

Edited by onjegolders
Link to comment
Share on other sites

Is there some caching taking place somewhere perhaps? Can you go to your site's cache folder (site/assets/cache off the top of my head) and delete the contents and see what happens then.

Link to comment
Share on other sites

I am so so so so so sorry...

Is there a dunce's hat to wear as I will gladly put it on now and wear it for a week or two.

Needless to say it was my stupid error, can anyone guess what it was?

(perhaps I should make this into a poll so everyone can have a chuckle at how stupid I am!)

  • Like 1
Link to comment
Share on other sites

We all do it from time to time http://processwire.c...rray/#entry9345

Thanks Dave though your mistake wasn't that bad!

It certainly didn't involve you have two instances of the same site admin open (one live and one localhost), making changes to localhost and wondering why the live version's menu wasn't updating properly!

Then getting all those lovely helpful people on the Processwire forums to scratch their heads over it!

Sincere apologies :)

Link to comment
Share on other sites

two instances of the same site admin open (one live and one localhost), making changes to localhost and wondering why the live version's menu wasn't updating properly!

I've done the same thing many times - some time ago I had a static link to the live site url behind the logo of both live and development sites (not in PW, obviously) and I was always in the wrong backend or frontend.

In fact, I ended up changing the CSS on each so the dev site had a different coloured background to remind me which was which!

  • Like 1
Link to comment
Share on other sites

My bet is you looked at wrong installation.

:-)

Bingo!

I've done the same thing many times - some time ago I had a static link to the live site url behind the logo of both live and development sites (not in PW, obviously) and I was always in the wrong backend or frontend.

In fact, I ended up changing the CSS on each so the dev site had a different coloured background to remind me which was which!

A genius idea that I may well implement.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...