Jump to content

Best practice for "hidden in menu" page type - navigation, template field or…?


Webrocker
 Share

Recommended Posts

Hi,

first of all thanks for this amazing CMS. I'm currently building my first page with PW, and I really like the concept. I have long years of experience with TYPO3, Wordpress, Joomla and some other more exotic systems, and I think PW just rocks, but I have difficulties to find the right/smart way for my ideas, due to lack of experience and know-how in the PW world. I guess what I'm trying to say -- be patient if waht I'm asking has been dealt with before or is a no-brainer for you guys with more PW-experience. :-)

I have a page "events" that I want to show in the navigation(s), since it features some editor-content. Sub pages of this will be "event" pages, and they shouldn't be showing in the main-navigation(s), since they will be linked via teaser boxes and such. Maybe later on, there will be the need to browse these events via their own navigation, but not right now.

I understand that I can control the visibility of the "event" page via the page option. Now, it would be possible, but not comfortable, to ask the editor to make sure that "event" pages are published, but not visible. From my experience, this sooner or later will be trouble, because, well, people, you know… ;-)

Is it possible to have a "default" status of published pages set (via the parent template)? -- I didn't find that kind of setting in the admin.

Another way would be to control the navigation via the template, by simply not showing child pages when on the page "events".

Now this is not so smart in my setup, because I opted to use the "MarkupSimpleNavigation.module" to build the main navigation and the navigation that'll show up on the page/content, if child pages are present. I found no way to tell the module to ignore (visible) child pages if in context of a certain page (other than to change the max level or depth setting). Currently I'm using a nav_main.inc.php and nav_sub.inc.php include throughout my frontend templates; I think it would be possible to switch the navigation module's behavior by chekcing for the page that includes them - but I don't want to clutter my code with if/else or switch conditions, if it can be avoided somehow :-)

So I think it boils down to:

  • Either a way to set the visibility for new pages under "events" to hidden by default - which would work without the need to touch the navigation module, but may be not future-proof
  • or a way to tell the navigation module if included in the "events" template to ignore the child pages, which can be done in several ways.
  • A third way could be to separate the "events" content page from the "events" container page, but that's kind of, uhm, ugly :-)

I think the second way is the way to go, but out of curiosity, how would you take on the first one?

Thanks for reading all this,
Tom

Link to comment
Share on other sites

Hi Tom!

There are indeed several ways to manage this!

Your first choice to set the visibility to hidden would be handled by creating a custom module. Your code would hook into the page creation/page save events, check the template for "event", and set the page to hidden. There are several modules in the Modules directory that will hook into the same place which you could look at for examples on how to do it. One that springs to mind is the Date Archiver module.

I don't use MarkupSimpleNavigation, but I think it would be able to support what you want somehow. If you check the documentation, it seems you could do it one of two ways:

1. Use the "selector" configuration option. You might be able to specify "template!=event".

2. It looks like you could use "nav_selector" to customise the output for that section of the website.

  • Like 1
Link to comment
Share on other sites

Hi Craig,

thanks for the fast reply :-) and the nudge towards the module's github page.

$pages->get(1001)->my_selector = "template=projects";

$options = array(
  "selector_level1" => "template=ressort",
  "selector_level2" => "start=0, limit=10",
  "selector_level3" => "template=news|events, sort=-created",
  "selector_field" => "my_selector"
);

echo $nav->render($options);

I completly missed the nav_selector power somehow when I implemented my navigation. cool.

Tom

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...