Jump to content

MarkupSimpleNavigation


Soma

Recommended Posts

Soma,

what a great module!

Is it possible to highlight the whole "navigation-path" to the current page?
Means that all of the parents need to get the 'current' class too.

- Level1

- Level1

-- Level2

--- Level 3

- Level 1

I didn't found any related posts to this question.

Thank you for all your efforts.

Link to comment
Share on other sites

Hi :)

and once again a newbee question from me... For some reason I am not able to make the following code work. It outputs the navigation not from page 1001 but from the real root, page 1. And I'm scratching my head asking why...

<?php
$teaser1 = $modules->get("MarkupSimpleNavigation");
			$options = array(
			    'levels' => false,
			    'max_levels' => 1,
			    'show_root' => false
			);
$rootTeaser1 = $page->get(1001);
echo $teaser1->render($options, null, $rootTeaser1);
?>

Can you help me finding out why it ignores my custom root? And yes, 1001 does exist and has non-hidden children nodes.

Thanks in advance!

Marcus

Link to comment
Share on other sites

Sorry,

it's me again, but i don't get it.

I need to render the Nav for a defined set of ids (eg. id=1015|1016|1017|1018).

I'm not sure how to set the selector right. Even if i only use one page via id|has_parent the module is not rendering thru the levels.

What am i doing wrong?

Thanks!

Link to comment
Share on other sites

Sorry,

it's me again, but i don't get it.

I need to render the Nav for a defined set of ids (eg. id=1015|1016|1017|1018).

I'm not sure how to set the selector right. Even if i only use one page via id|has_parent the module is not rendering thru the levels.

What am i doing wrong?

Thanks!

I'm not sure what you're trying, but the module expects a "root" page from where it renders the children of that page.

On a side note "has_parent" only accepts one id and only makes a difference if the parent is one of the children of the root page.

To understand a little better, can you explain what you want with those id's? Are those the only page that should show up, or are they the "parents" from where it should render a nested navigation?

Link to comment
Share on other sites

Hard to explain.

Let's say we got the following constellation:

Root (1000)

- Level1 (1001)

- Level1(1002)

- Level1(1003)

-- Level2(1011)

--- Level 3(1021)

- Level1(1004)

- Level1(1005)

And now i need to render the navigation including all subnavigations for the ids 1002, 1003, 1004. It has to be "hardcoded" via ids because have no other chance to differentiate between the the pages on level 1.

If i call the module three times with other rootpages, it works. But isn't there a better way to do only one rendering call by using the selector option?

Thank you for your support.

Link to comment
Share on other sites

I'm not sure I understand, but can't you just set them "hidden"?

The include this and that ID approach won't work with hierarchical tree of course, but exclude would.

"id!=1001|1005"

"parent=1002|1003" would also work but only for direct children.

"has_parent=1002" only works for 1 parent, but would include all children levels.

So best option is the one built for such things, make the pages "hidden".

Link to comment
Share on other sites

If you think I missunderstood, why not show what the result should be like?

I think I understood what you want and showed what parent and has_parent does. There's so many ways to archive something there might be a better solution. You could for example add checkbox to top level pages and use that instead of making the top level pages you dont want to show hidden.

Link to comment
Share on other sites

Soma,

thank you for not giving up on me! :-)

My "wish" is still to have an defined array of "parent-ids" and the module should render the navigation for only these ids including all subnavigations in one call.

Let's say we have the following structure:

Home/Root
- Company
-- About
-- Team
- Products
-- Category 1
--- Subcategory 1
--- Subcategory 2
-- Category 2
--- Subcategory 1
--- Subcategory 2
- Services
-- Service 1
--- More services 1
--- More services 2
- Directions
- Contact
- Impress

This is the whole navigation tree and it's used all over the website. In some special cases i only want to show the navigation for Products and Services.

My simple snippet
 

$ids = "1015,1016";
$navigationHeaderMain = $pages->getById($ids);
foreach($navigationHeaderMain as $nht) {
    $customRoot = $pages -> get($nht->id);
    echo $treeMenu -> render($options, $page, $customRoot);
}

doesn't work out, because it will output two lists <ul><li>Products... <ul><li>Service... and even if i set show_parent to true the "root" (Products, Service) are not included correct in the list.

Can you follow?

If it is possible to set a flag (checkbox) like "add this page to my customNavigation" as you mentioned in your post, it would be perfect! But what is the correct statement for the 'selector'? I have no clue.

Thank you so much for all your efforts!

Link to comment
Share on other sites

Ah I think you're best off with setting the outer wrapper template to '||' and add opening and closing UL after.

I then also think it would be nice to have a include in the top level thing.. and if has_parent would allow multipe it would already be easy... have to think a little more.

With checkboxes it would still be the same issue with parents.

  • Like 1
Link to comment
Share on other sites

I'm wondering: is there a way to influence the parent item - like it's possible to influence the current one?

A counterpart of "item_current_tpl", such as "item_parent_tpl"?

Why do you want this anyway? The current parents are already marked with a class you can define. Default "parent".

I'm not too excited to add another template option, as we will have a new option every other week someone thinks this would be useful.

However, for that reason I created a function (getTagsString) you can hook into to change a child's output. There's some example further up this thread, but just to give another example:

$nav = $modules->get("MarkupSimpleNavigation");

function hookTagString(HookEvent $event){
    $child = $event->arguments('page'); // current child in navigation
    $parents = wire("page")->parents; // parents of current page
    if($parents->has($child)){ // is current child an active parent?
        $event->return = "<span class='parent'>$child->title</span>"; // return something
    }
}

$nav->addHookAfter('getTagsString', null, 'hookTagString');

echo $nav->render();
  • Like 1
Link to comment
Share on other sites

Hi Soma,

thanks for this approach! I was kind of thinking out loudly - I hope it wasn't understood as a feature request and totally can understand that you aren't looking forward to adding every special request into the module core. I'll try to implement a hook like this - thanks again for pushing me in the right direction!

Best,

m

Link to comment
Share on other sites

Home

Child 1 (child of parent :) ) - class for this....and more below...

Grandchild 1 1 (another child of parent ;), so etc. )

Great grandchild 1 1 1

Grandchild 1 2

Child 2

 Grandchild 2 1

 

 

A child class will potentially cause conflict with parent and has_children classes in cases where children are themselves parents :)  :undecided:

CSS maybe? 

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