Jump to content

Recommended Posts

Posted

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!

Posted

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.

Posted

Thanks for the suggestion Pete, no I just tried logging out but same story.

Strange really, the pages are definitely "hidden" and the order is different.

Posted

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!)

Posted

Not sure what it's about, but you could debug it using isHidden() http://processwire.c...filter=isHidden and see what status they really have.

As for the sorting it can have different reasons, not sure though. Try reorder the pages so it get updated (last to first pos). Also you can use the sort=sort selector on the children.

Posted

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 :)

Posted

Thanks both of you.

Turns out they are all visible...

A bit stumped here to be honest.

Have included screenshots just to be sure I'm doing the right thing to make a page not appear in the menus!

post-502-0-03658800-1344509433_thumb.png

post-502-0-87013700-1344509433_thumb.png

post-502-0-45759800-1344509434_thumb.png

Posted

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.

Posted (edited)

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
Posted

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.

Posted

Do database repair (can be done from phpmyadmin), also try saving your home page and also all direct children.

Posted

Thanks Pete, Apeisa.

I've tried every one of those things and still same issue. Really strange.

The repair all had status as "OK", presume that means all is well?

Posted

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
Posted

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 :)

Posted

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
Posted

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.

Posted

I've done this a couple of times recently and changed my dev copy to say "Development" in big letters at the top ;)

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
×
×
  • Create New...