Jump to content


Photo

Navigation outputting even "hidden" pages

navigation hidden

  • Please log in to reply
22 replies to this topic

#1 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 08 August 2012 - 03:25 PM

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!

#2 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 09 August 2012 - 01:50 AM

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.

#3 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 02:31 AM

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.

#4 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 03:48 AM

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

#5 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1765

  • LocationSH, Switzerland

Posted 09 August 2012 - 05:21 AM

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.

@somartist | modules created | support me, flattr my work flattr.com


#6 slkwrm

slkwrm

    Sr. Member

  • Members
  • PipPipPipPip
  • 248 posts
  • 66

Posted 09 August 2012 - 05:40 AM

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

#7 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 05:50 AM

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!

Attached Thumbnails

  • Screen Shot 2012-08-09 at 12.48.35 PM.png
  • Screen Shot 2012-08-09 at 12.48.47 PM.png
  • Screen Shot 2012-08-09 at 12.49.00 PM.png


#8 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1765

  • LocationSH, Switzerland

Posted 09 August 2012 - 06:07 AM

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.

@somartist | modules created | support me, flattr my work flattr.com


#9 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 06:14 AM

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!

Attached Thumbnails

  • Screen Shot 2012-08-09 at 1.10.59 PM.png

Edited by onjegolders, 09 August 2012 - 06:18 AM.


#10 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 09 August 2012 - 07:11 AM

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.

#11 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 09 August 2012 - 07:21 AM

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

#12 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 07:45 AM

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?

#13 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,530 posts
  • 859

  • LocationVihti, Finland

Posted 09 August 2012 - 07:52 AM

Running latest and greatest version of PW?
twitter ·· my modules

#14 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 07:54 AM

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

#15 DaveP

DaveP

    Sr. Member

  • Members
  • PipPipPipPip
  • 287 posts
  • 138

  • LocationChorley, UK

Posted 09 August 2012 - 07:58 AM

We all do it from time to time http://processwire.c...rray/#entry9345
Twitter : Facebook : GitHub : G+ : Blog : Powered by C8H10N4O2 and C10H14N2

#16 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 08:03 AM

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

#17 slkwrm

slkwrm

    Sr. Member

  • Members
  • PipPipPipPip
  • 248 posts
  • 66

Posted 09 August 2012 - 08:06 AM

Glad you solved it, whatever it was :)

#18 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 806 posts
  • 212

  • LocationMidlands, UK

Posted 09 August 2012 - 08:07 AM

Glad you solved it, whatever it was :)


Thanks mate, though the problem was my brain, so not sure I can claim it's been 'solved'!

#19 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1765

  • LocationSH, Switzerland

Posted 09 August 2012 - 08:09 AM

My bet is you looked at wrong installation.
:-)

@somartist | modules created | support me, flattr my work flattr.com


#20 DaveP

DaveP

    Sr. Member

  • Members
  • PipPipPipPip
  • 287 posts
  • 138

  • LocationChorley, UK

Posted 09 August 2012 - 08:15 AM

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!
Twitter : Facebook : GitHub : G+ : Blog : Powered by C8H10N4O2 and C10H14N2





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users