modx revo: wayfinder doesn't sort by menuindex - modx

By default, the wayfinder plugin in modx revo should sort by menuindex. This doesn't seem to work. I have the following:
[[!Wayfinder? &startId=`2` &level=`1` &ignoreHidden=`TRUE` &outerClass=`news` &sortBy=`menuindex` &sortOrder=`DESC`]]
I suspect it's something stupid I overlooked...
EDIT: I've made it work now.
I looked into the wayfinder code in wayfinder.class.php. The following line was commented out:
$c->groupby($this->modx->getSelectColumns('modResource','modResource','',array('id')));
It happened because of the following comment in the code:
/* not sure why this groupby is here in the first place. removing for now as it causes issues with the sortby clauses */
Maybe this will help someone in the future.

I looked at the wayfinder code in wayfinder.class.php The following line was commented: $c->groupby($this->modx->getSelectColumns('modResource','modResource','',array('id')));
It was commented out because of the following comment in the code:
/* not sure why this groupby is here in the first place. removing for now as it causes issues with the sortby clauses */
Maybe this helps anyone in the future

Related

Calling a template variable from an output modifier in Modx?

I'm trying to output a template variable inside the if statement in ModX, but it gives no output.
I have multiple pages with links to articles and the point is to only output template variable content on the first page but not the others.
// This gives no output:
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=``]
// This outputs "yes" on the first page and "no" on others:
[[!#get.page:is=`1`:or:is=``:then=`yes`:else=`no`]]
I've even tried this, but it still does not give any output. I guess the problem is not about the output modifier:
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=`[[*content]]`]
I'm using ModX Revo 2.7.0
Any help is appreciated, thanks in advance!
Actually in your case missing a double closing angle bracket "]]"
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=``]]
The `or:is=` is matching against an empty state. Unless that is intentional you should be able to remove it. Also, the `:else=`` is the default state, so, you don't need that either.
The following should work and you'll have cleaner code:
[[!#get.page:is=`1`:then=`[[*content]]`]]

How can I add multiple GridBagLayout attributes in the 'Constraints' section of an element in Groovy (2.5.5)?

This is driving me mad at the moment, if anyone can help it would be much appreciated!! This is simple enough in Java, but when called from groovy I cannot get multiple gbc properties defined in a single constraint.
I have read on a couple of old posts on the net that GridBagConstraints properties such as gridx etc can be added as follows from here.
code snippet of interest:
label(text:'Username', constraints:gbc(gridx:0,gridy:0,gridwidth:2))
However this won't work for me and I didn't expect it to as the syntax appears to be from years ago so I assume an old API. (error message below when I try the above)
Caught: java.lang.IllegalArgumentException: cannot add to layout: constraint must be a string (or null)
I can't see how this could work as as surely the format needs to be:
GridBagConstraints gbc = new GridBagConstraints()
label("Username: ", constraints:gbc.gridx=0)
The two lines of code above run, but then I have the problem that I can't add more than one entry in the 'constraints:' section, and obviously I need to add 'gridy=0' etc.
Has anybody got any solution on how this should work?
Thanks
Taylor.

MODX SimpleSearch not highlighting results

I want to use &highlightResults as shown in the RTFM to add a class to the keywords that appear in the results. However, this doesnt seem to work.
My snippet call looks like:
[[!SimpleSearch?
&ids=`21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,44,22`
&idType=`parents`
&tpl=`SearchResultTpl2016`
&containerTpl=`SimpleSearchContainerTpl`
&highlightResults=`1`
&includeTVs=`1`
&processTVs=`1`
&showExtract=`1`
]]
I tried adding:
&highlightClass=`sisea-highlight`
&highlightTag=`span`
as well but it made no difference.
Would anyone know what I'm doing wrong here?

modx - getPage - [[+pageNav]] Placeholder always has a value

I try to hide the getPage [[+pageNav]] Placeholder if there is no pagination. But I can't do the following.
[[!+pageNav:notempty=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]
Does someone know how I can hide the element with an apropriate output filter? (without own extra snippet). I also tried the following and some other (not likely to work variations).
[[!+pageNav:isnot=``:then=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]`
Are you calling that code in a chunk that is cached?
Otherwise i've experienced this aswell and it seems custom placeholders sometimes behave that way, it's probably due to the fact that they actually have some unprocessed value during the IF computation but when it's actually output you see nothing. Or that the value is somehow "null" instead of "" while modx output filter might do a strict comparison.
If you're not calling it in a cached chunk or part of code, i suggest first trying with another getPage placeholder such as pageCount or total.
Like:
[[!+pageCount:gt=`1`:then=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
If that still doesn't work, a last resort in the form of a simple snippet will always solve it, like:
[[!outputPagination? &total=`[[+total]]` &limit=`XX` &output=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
In snippet:
if ($total > $limit) {
return $output;
}
Shouldn't it be...
[[!+page.nav:notempty=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
Well, there is a much more easier way to do it than in the first answer. It's like TheMistaC says, even if my answer is a lot easier:
[[!+page.nav:notempty=`
[[!+page.nav]]
`]]
I use it to display a list of articles with getResources, so I know this works fine.

Vim NERD-Commenter: How to uncomment only first level of comments, without uncomment nested comments?

I got a problem with NERD-commenter.
If I <leader>cu the following code:
/*function func(arg) {
codeish; // Nested comment.
}*/
This is the result:
function func(arg) {
codeish; Nested comment.
}
Note the 2nd line: The nested comment was also uncommented. This is not good.
Perhaps I'm just not using it right. How can I avoid this?
Well, if you're the one who has commented out the function, you can avoid it by using <leader>cc to comment it out in the first place. In this way, the function will get commented out in a different way, and subsequent <leader>cu will work as expected.
If, however, you want to use NERD Commenter to uncomment blocks of code which have been commented out manually (or using a different tool), I don't know how would you go about it. After all, the cc and cu commands are meant to be reciprocal.
This bug was fixed in the latest version of NERD-Commenter.

Resources