Jump to content
Soma

MarkupSimpleNavigation

Recommended Posts

Hi Soma,

is it possible to make all parents active of an active child?

Example, active pages in bold.

- page 1

- page 2

--- sub 1

--- sub 2

------ subsub 1

------ subsub 2 (the actual active page)

------ subsub 3

--- sub 3

- page 3

I somehow cannot get the parents to have an active class. How would I do that with the module?

Thanks!

Share this post


Link to post
Share on other sites

@Soma thanks, that worked. I did not associate the name and description of that config setting with this kind of functionality.

Share this post


Link to post
Share on other sites

Hallo,

does anyone know how to realize a navigation with MarkupSimpleNavigation that starts eg. at level 3?

I don't know how to set the starting point for a lower level... :'(

(First Navigation)

-Home

-Level1

    --Level2

    --Level2

-Level1

    --Level2

    --Level2

-Level1

    --Level2

......

I'm looking for something like this (Second Navigation):

---Level 3

---Level 3

---Level 3

.....

addition: The third Level (Level 3) is dependant on the second Level (Level2)...

Thanks for your help!

Share this post


Link to post
Share on other sites

Hi totoff,

thanks for your reply. I have already tried this, but there is a problem when level 3 is activated (page on level 3 is the current level) -> level 3 is not displayed!

$root = $page->children('template=xyz_template');

$sub_nav = $nav->render($sub_nav_options,null,$root);

I  have found a  (quick-and-dirty) solution by myself:

// Nav-Level 3;

switch (count($page->parents)) {

case 2:

  $root = $page;

  break;

case 3:

  $root = $page->parent;

  break;

default:

  $root = false;

}//end switch

$sub_nav = $root ? $nav->render($sub_nav_options,null,$root) : false;

.....

....

But maybe anyone know a better solutions for this.

Thanks!

Robert

Share this post


Link to post
Share on other sites

Hi Robert,

$root = $page->children('template=xyz_template');

This defines the children of the current page as root page (presumably level 2 in your site tree if I understood you right). So the pages on level 2 and 3 (in the site tree) should show up in the menu if you have the following options defined:

'show_root' => true,
'max_levels' => 2, 

 If they nevertheless don't render I would first of all check if

$root = $page->children('template=xyz_template');

returns an empty array.

Share this post


Link to post
Share on other sites

@totoff thanks, but what i am looking for is, that only pages of level 3 (in the site tree) should appear the in the sub_menu  whether pages from Level 2 (main_menu) or Level 3 (sub_menu) are selected...

Share this post


Link to post
Share on other sites

@ro-bo Your solution is the only way to go. I'm using same technique on some sites. I don't think it's dirty, this way it's actually pretty flexible, powerful and simple.

Edit: But I'm open for suggestions on how such cases could be solved differently.

Share this post


Link to post
Share on other sites

Hey Somma, I have not read the thread, sorry if I am duplicating content.

I have the Multisite module installed and have the module working perfectly, however I am concerned if my config in MarkupSimple nav might be unexpected behavior.

My options for markup simple nav that is relevant:

- I am ignoring all templates that have the name home

- and show_root=true

ie Options are

<<--edit: add method get root -->>

function getRoot($httpHost) {
$root =  $this->pages->get('name='.$httpHost);
if (!!$root->id) {
  return $root;
}
  return $this->pages->get('/');
}

<<--edit -->>

$options = array_merge(array(
    'current_class' => 'menu__item_-current',
    'parent_class' => 'menu__item_-current-parent',
    'outer_tpl' => '<ul class="menu_-primary">||</ul>',
    'inner_tpl' => '<ul class="menu menu__sub">||</ul>',
    'selector' => 'template!=rss|home',
    'show_root' => true,
    'list_field_class' => 'menu__item menu__item_-primary',
    'item_tpl' => '<a href="{url_nav|url}">{title}</a>',
    'item_current_tpl' => '<a href="{url_nav|url}">{title}</a>'
), $options) 

I also have the rootPage being overwritten in the render function like so 

<<--edit: add method get root -->

$modules->get('MarkupSimpleNavigation')->render($options, null, $this->getRoot($this->config->httpHost))

<<--edit -->

, obviously returning a page with template named home.

It works as expected. Rendering the page without errors and returning a navigation containing the sub domain as home, meaning the first page and also the root page using template home, and all other sub pages of said sub domain. Even more It ignores all subdomains on the parent domain. Is this what I should expect?

ie ProcessWire admin tree:

-home

  -about

  -bla

  -subdomain.example.dev

    -about sub

    -bla sub

on the site the nav will contain

if at example.dev

home | about | bla 

or

if at subdomain.example.dev

subdomain | about sub | bla sub

Share this post


Link to post
Share on other sites

I'm not sure I can follow you in all regards. Trying to decifer what you wrote especially the last sentence.

And your post is doubled. :)

Not sure what you mean by ignoring "home" template and what that pages are exactly. And where and how?

Anyway just from a glance, a call like $this->pages->get('name='.$this->config->httpHost)) will always return the page no matter what template, status etc. It's like $page->get(id).

Share this post


Link to post
Share on other sites

Hi somma, sorry about the duplicate, I have revised my post. Clarifying the intent of some words and adding structure stuff :)

Share this post


Link to post
Share on other sites

Sorry that still doesn't do it for me. Still same. If I need more than 5 min to even imagine what you trying to show/say I can't help. Also show some more code like what is $options etc.

Just looking at the last "what you get and how it should be" thing, I don't see anything wrong here. But yes not sure I even understand what the question is.

Share this post


Link to post
Share on other sites

Revised :), the question is this:

Should what I am getting, which is what I want and expect, be a concern, because the ignored template is the same as the root template, or is this how things should work?

Share this post


Link to post
Share on other sites

Looks expected to me.

The template!=rss|home doesn't affect root page, only the children. It's the starting point, thus it can't ignore it.

  • Like 1

Share this post


Link to post
Share on other sites

The code of he "Advanced example with hooks - creating a bootstrap 2.3.2 multilevel navbar" is put in a template file ?

Share this post


Link to post
Share on other sites

@Soma

Have you plans for  an active/here class? It's different than the current class as it's applied to the parent list items

In MODX Wayfinder, this was called the &hereClass

&hereClass 
CSS class for the items showing where you are, all the way up the chain. 
CSS = .active 

So if I was currently on a page called Pluto below, the active classes would be applied as follows...

Nature

Geography

Astronomy (active)

 - Solar Systems

 - Planets (active)

 - - Mars

 - - Pluto (current)

 - - Venus

 - Black Holes

Share this post


Link to post
Share on other sites

There should be no Problem:

Quote from soma page 16:

If I select the service one or two links in the services parent page, the children's class is "active" can I set the parent to "active" too?

Yes you can.

'parent_class' => 'active', // string (default 'parent') overwrite class name for current parent levels
  • Like 1

Share this post


Link to post
Share on other sites

Guys - you're right. Problem at my end with my list items and formatting didn't help. 

  • Like 1

Share this post


Link to post
Share on other sites

hi guys i want to list on a side menu which only contains active pages childrens. page with same template.

if i made $RootPage = $page->parent; and render it with $SideList->render(null,$page,$RootPage) works fine but in services main page lists all sub pages.

if i made $RootPage = $page->children; and render works fine but child pages does not contains same level pages.

i want it on service page menu displays service#1, service#2, service#3

on service#1 page menu displays the same (service#1, service#2, service#3)

or other page on product menu displays (product#1, product#2,product#3)

on product #1 page menu (product#1, product#2,product#3)

i cant do this with same template

Share this post


Link to post
Share on other sites

ahh i made it with $RootPage= $page->rootParent

i waste my few hours with it :)

Share this post


Link to post
Share on other sites

Working on a site and for some reason show root, adds the homepage to the end of the nav? I thought this was prepended so not sure why it is ending up at the end of the nav. Not seeing any options for root position. Any ideas?

Share this post


Link to post
Share on other sites

This module is so amazing great!

There is no task of navigation that can't go throw this nice piece of code....

Sorry for this idle post - but i think complimenting is important, too ;)

Jus finished my first MarkupSimpleNavigation with the use of the build in hooks to get a MegaMenu working fine...take me only some minutes until i found this gist:

https://gist.github.com/somatonic/6258081

Thank you very much Soma i love it!

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      This is a new module that provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Beta release
      Note that I consider this a Beta release. Since the module is relatively aggressive in deleting some caches, I would advise you to install in on a test environment before using it on a live site.
      Let me know if you're getting any errors, have trouble using the module or if you have suggestions for improvement!
      In particular, can someone let me know if this module causes any problems with the ProCache module? I don't own or use it, so I can't check. As far as I can tell, ProCache uses a folder inside the cache directory to cache static pages, so my module should be able to clear the ProCache site cache as well, I'd appreciate it if someone can test that for me.
      Future plans
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory

    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="optin" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="optin" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: https://github.com/blaueQuelle/privacywire/tree/master
      Download: https://github.com/blaueQuelle/privacywire/archive/master.zip
      I would love to hear your feedback 🙂
      Edit: Updated URLs to master tree of git repo
       
    • By David Karich
      Admin Page Tree Multiple Sorting
      ClassName: ProcessPageListMultipleSorting
      Extend the ordinary sort of children of a template in the admin page tree with multiple properties. For each template, you can define your own rule. Write each template (template-name) in a row, followed by a colon and then the additional field names for sorting.
      Example: All children of the template "blog" to be sorted in descending order according to the date of creation, then descending by modification date, and then by title. Type:
      blog: -created, -modified, title  Installation
      Copy the files for this module to /site/modules/ProcessPageListMultipleSorting/ In admin: Modules > Check for new modules. Install Module "Admin Page Tree Multible Sorting". Alternative in ProcessWire 2.4+
      Login to ProcessWire backend and go to Modules Click tab "New" and enter Module Class Name: "ProcessPageListMultipleSorting" Click "Download and Install"   Compatibility   I have currently tested the module only under PW 2.6+, but think that it works on older versions too. Maybe someone can give a feedback.     Download   PW-Repo: http://modules.processwire.com/modules/process-page-list-multiple-sorting/ GitHub: https://github.com/FlipZoomMedia/Processwire-ProcessPageListMultipleSorting     I hope someone can use the module. Have fun and best regards, David
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "https://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


×
×
  • Create New...