Jump to content
Soma

MarkupSimpleNavigation

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.

Share this post


Link to post
Share on other sites

There is, the parent option add classes to all parents.

  • Like 1

Share this post


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

Share this post


Link to post
Share on other sites

It should be $pages->get (1001)

Share this post


Link to post
Share on other sites

Try: 

$rootTeaser1 = $pages->get(1001);

Share this post


Link to post
Share on other sites

*facepalm*  Thanks! Arrghh....

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Soma,

my explanation wasn't the best, so i think we are talking past each other.

But never mind, i'm now excluding the ids i do not need.

It's more or less a workaround, but it works perfect.

Thank you.

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Any thoughts on how to use this module together with your LanguageLocalizedURL Module??

There's nothing special about it, it just works. Page url is localized automaticly by current user language.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Sorry Soma, 

Is that not the class for the parent itself, I was looking for a class for the child of a parent. Only ask I was having trouble targetting a specific "option" for a mobile nav. (I did read the docs I promise :))

Share this post


Link to post
Share on other sites

I have trouble understanding what you want and why? A child of a parent?

Share this post


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

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