Is it possible to replace Wayfinder and UltimateParent by pdoTools?

Hi everyone.

I am working on this Modx website, and I am trying to fix the sidebar. The person who made the website used 2 plugins:

[[!Wayfinder? &startId=`[[UltimateParent? &topLevel=`3`]]` &levelClass=`nivel` &removeNewLines=`false`  &selfClass=`class_active` &ignoreHidden=`0` &parentClass=`parent_active` &level=`0` &startItemTpl=`tpl_nav_gauche` ]]

The code above works (moreless), but becomes buggy once you start to visit subpages.
Is there a way to make the Ultimate Parent relative to the folder?

Also, is the code above “well written”, or should I switch the pdotools? The ultimate parent plugin hasn’t receive any updates from years, so it makes me worried.

Thanks for your help.

It’s hard to say if these snippet tags are correct, without knowing the details of what you’re trying to achieve.

Maybe you can hard-code the &startId and don’t need the UltimateParent snippet.
You could replace Wayfinder with pdoMenu, but this shouldn’t change anything.
Also, there is usually no need to call Wayfinder uncached. [[Wayfinder? ...]] should be fine.


This extra is just one snippet with about 20 lines of code. So there’s not much to update.

1 Like

Is there a way to make the Ultimate Parent relative to the folder?

well first of all try to call UltimateParent uncached as well - because you call Wayfinder uncached.

Is it possible to replace Wayfinder and UltimateParent by pdoTools?

Yes it explicitly is. Use pdoField (part of pdotools) for this:
https://docs.modx.com/3.x/en/extras/pdoTools/Snippets/pdoField

This should do it I think.
[[*id:pdoField={“topLevel”:1,“field”:“id”}]]

I personally could think of no reason why not to use pdoTools. I use pdoTools a lot in similar cases.

pdoTools should make this a quite easy task since it is designed to be very interchangeable with wayfinder. use pdoMenu in this case:

https://docs.modx.com/3.x/en/extras/pdoTools#pdomenu

1 Like

Try this one:

[[pdoMenu? 
	&tpl=`@INLINE <li[[+classes]]><a href="[[+link]]" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]]</li>`
	&tplStart=`@INLINE <li[[+classes]] data-isstart="1"><a href="[[+link]]" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]]</li>` 
	&parents=`[[*id:pdoField=`{"topLevel":1,"field":"id"}`]]` 
	&showHidden=`0`
	&displayStart=`1`
	&level=`0`
	&levelClass=`nivel` 
	&selfClass=`class_active` 
	&parentClass=`parent_active`
]]

Use your own “&tpl” and “&tplStart” chunks as needed.

Some of the Options with pdoMenu are different, often more meaningful:

  • The option “startId” is called “parents”.

  • The option “ignoreHidden” is called “showHidden”.

  • The Option “startItemTpl” is called “tplStart”.
    (make sure you add &displayStart=1 if you need a tplStart… this at least is incoherent in your Wayfinder call)

  • The option “&removeNewLines=false” is not known by pdoMenu as far as I know. By default it doesn’t separate tags with newlines. You could however place newlines in the tpl-chunks if you need them.

Compare the output of Wayfinder and pdoMenu to find the right options.

By default always use the cache - it’s your friend. As halftrainedharry already said.
Skip the cache only if actually have a reason to do so.

No matter how often I use pdoTools I always have the manual at hand. In this case:
https://docs.modx.com/3.x/en/extras/pdoTools/Snippets/pdoMenu

One more thing: I personally prefer pdoMenu over Wayfinder, if for no other reasons because it’s at hand with pdoTools (which I like for several other reasons). But. Wayfinder should - still - do the job. Provided the tag is written right.

2 Likes

Using the pdo… extras should give you faster page loads. If you’re not referencing any TVs in your tags, the direct replacement should work.

1 Like

Hi, and thank you all for your replies. Sorry I wanted to reply sooner but got a massive headache yesterday :upside_down_face:.

Yes, I will try to get rid of Ultimate Parent.

Thanks a lot for your very detailed reply! I am definitely going to switch to pdotools.

Yes I will, agreed pdotools is faster.

Update:

@domindian your code works great! I just had to change the value &displayStart=0
It’s crazy to think how versatile pdotools is.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.