Jump to content

Direct children of default front page


ezeey
 Share

Recommended Posts

First of all: I love Processwire and feel a strong urge to migrate all my clients systems from MODx ;)

Still, I have a little problem just now:

I need to add two direct children to my front page (the top of the tree, which is opened on page load). I want the front page to appear in my menu (Already did this with MarkupSimpleNavigation) and have two direct child pages. Is there any way to accomplish this? 

I thought about just using the top-element as an empty one and somehow mark another page, which can have as many children as I want, as the default front page.
  • Like 1
Link to comment
Share on other sites

Hi

Do you mean you want the child pages as dropdowns under home?

That is possible if you get a simply by how you mark up your menu code (and Soma's Simple nav will probably make that easier.

The only problem, however, is if you want other top level menu items.

In practice, Home is the head of the tree, with everything else as a child. On menu markup, what normally happens is that the top level of the menu is actually made up of all the first level children of Home, ignoring the home page entirely, and then Home is added as an extra link on the front or the end (append or prepend)

What you may need to do is to create the menu as normal, but leave out the home link initially, then add a home page link with a custom drop down just for this case.

As Arjen said, if you want to give a rough outline as to how you want your front page to work, then we can give you some help and advice.

Joss

Link to comment
Share on other sites

Sorry for the difficult explanation, but Joss got it exactly right.
I like your attempt of manually creating a custom dropdown but since I am not really a PHP guy I am quite helpless in how to implement it.
My idea would be to create a new (hidden?) child of the root page and manually add its children as children of the rootPage when rendering the menu tree. Does anyone have a suggestion how I could accomplish this? Otherwise I will just try to convince my customer of another solution ;)
//My Processwire tree would look like this  

Home
---Hidden Home
-----HomeChild1
-----HomeChild2
---Page1
-----Page1Child1
...

// My Menu would be rendered like that

Home...............Page1
...HomeChild1.........PageChild1
...HomecHild2...................
Link to comment
Share on other sites

I see what you mean. This would be my setup:

1. Create the normal structure (without the homepage children)

2. Add a checkbox fieldtype called "homechild" to your templates

3. Add the pages you want to appear under home directly under home and select the checkbox

Your pagestructure would look like this:

- Home

-- Page 1

--- Page 1 child

-- HomeChild1

-- HomeChild2

Use code like this:

Checkout this gist. (edited the original post I made tomorrow to use gist instead - thanks soma)

Written in the browser, but you should get the idea!

  • Like 1
Link to comment
Share on other sites

Glad to help. I hardly ever feel the need to use a custom menu. If that's the case my Information Architecture is probably bad. I really like the idea of ProcessWire that your pages reflect your menu and thus your url structure.

  • Like 2
Link to comment
Share on other sites

NIce solutions. I would solve it differently and not work against the natural structure but anyway. 1st world problem :) However up to you, if you feel happy with it, ok. 

Wanted to point out that you should write:

'outer_tpl' => '||',

Or it will throw a notice in debug mode and I think it may result in not closing or opening tag (maybe not)? It's expecting a || to split for the template to use. Well better just add it.

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