AgelxNash/DocLister

Filters with line spacing and tabs

nick0 opened this issue ยท 10 comments

nick0 commented

Hello,

Has anyone else's DocLister calls stopped working after updating to 1.4.6 with DocLister 2.4.0?

I have a few calls that have stopped working. I managed to fix a couple but am stuck on a few...

I tried to make sense of the 2.4.0 notes but I don't understand if that is the reason and if so how to fix in my instances.

  1. In 1.4.5 and previously, this filter used to work to show resources relative to TV selections. In 1.4.6 nothing is returned:
tv:blog-cat:like:med;
tvd:blog-archive:is:no

I tried this as an alternative but it lists all items (not taking into account med as TV selection

blog-cat:like:med;
blog-archive:is:no

Any ideas on what I need to tweak for 1.4.6 to get working?

  1. Images no longer show in any of my DocLister menus. This is my typical usage.
DocLister call...
[[DocLister?
	&id=`blog-grid[*id*]`
  	&idType=`parents`
	&parents=`97`
	&display=`9`
	&ownerTPL=`blog-grid-wrapper`
	&tpl=`blog-grid-row`
	&noneTPL=`blog-grid-NO`
	&tvList=`image`
	&orderBy=`pub_date DESC, pagetitle DESC` 
	&filters=`AND(
		content:c.isfolder:is:0;
		content:c.hidemenu:is:0;
		content:c.id:isnot:[*id*];
		blog-archive:is:no
	)`
]]

Row template (i tried this with tv.image and also just image. but it made no difference)..
<div class="item"><a href="[~[+id+]~]" title="[+pagetitle+]" class="th">
	[+tv.image:is=``:then=`<img src="assets/images/mix/image-placeholder.png" 
		srcset="
			assets/images/mix/image-placeholder.png 650w, 
			[[phpthumb? &input=`assets/images/mix/image-placeholder.png` &options=`w=480,h=300,q=80,zc=1,far=C`]] 480w, 
			[[phpthumb? &input=`assets/images/mix/image-placeholder.png` &options=`w=300,h=188,q=80,zc=1,far=C`]] 300w" 
		sizes="
			(min-width: 650px) 480px,
			100vw"
		alt="[*pagetitle*] image" />`:else=`<img src="[+tv.image+]" 
		srcset="
			[+tv.image+] 650w, 
			[[phpthumb? &input=`[+tv.image+]` &options=`w=480,h=300,q=80,zc=1,far=C`]] 480w, 
			[[phpthumb? &input=`[+tv.image+]` &options=`w=300,h=188,q=80,zc=1,far=C`]] 300w" 
		sizes="
			(min-width: 650px) 480px,
			100vw"
		alt="[+pagetitle+] image" />`+]
	<span><b>[[if? &is=`[+menutitle+]:!empty` &then=`[+menutitle+]` &else=`[+pagetitle+]`]] <i>[+pub_date:date=`%B %e, %Y`+]</i></b></span>
</a></div>

This one returns the correct documents but no images.
Is there something I need to change now for 1.4.6?

Thanks for any help.

pmfx commented

I have 1.4.5 website that uses a lot of DocLister filters.
@AgelxNash does that mean that I will have to rewrite some rules after upgrading to 1.4.6? ๐Ÿ˜จ

@pmfx No. Everything should work as before. Except some situation

pmfx commented

OK, that's good. So why @nick0 have some issues after upgrade? His snippet code is not complicated. I'm not sure where is the answer to his question under https://github.com/AgelxNash/DocLister/releases/tag/2.4.0

Before, some tips

Use table alias

&orderBy=`c.pub_date DESC, c.pagetitle DESC`

Don't use alias table with filter

&filters=`AND(
content:isfolder:is:0;
content:hidemenu:is:0;
content:id:isnot:[*id*];
tvd:blog-archive:is:no
)`

Use addWhereList instead of content filter

&addWhereList=`c.isfolder=1 AND c.hidemenu=0 AND c.id!=[*id*]`
&filters=`AND(tvd:blog-archive:is:no)`

Debug

Use the &debug = `1` option if you see the wrong result

At now back to the original call

Can you change the order of the filters and check the result?

&filters=`AND(
tvd:blog-archive:is:no;
content:c.id:isnot:[*id*];
content:c.hidemenu:is:0;
content:c.isfolder:is:0;
)`

If this doesn't help, I want to see debug result before and after upgrade

nick0 commented

Thanks @pmfx, I appreciate the support.

I have 1.4.5 website that uses a lot of DocLister filters.
@AgelxNash does that mean that I will have to rewrite some rules after upgrading to 1.4.6?

I had to change 90% of my DocLister calls and a couple of DLMenu calls. If your DocLister calls are anything like mine, you will probably have to make at least some changes to a number of your calls in every site you upgrade. Took 3/4 of a day for me to fix. Hopefully I don't have to repeat this process for the next release.

Thanks @AgelxNash, I appreciate the clearer examples. That has helped me to understand the new changes a little more but in my situation it still did not make a difference to question 2. The in built filters checking for an image tv stopped working in a number of my DocLister calls (but are working fine elsewhere in the site). Changing to the IF snippet fixed those and the images are now showing.

Resolved, thank you for your help.

Please give us a forum before v2.0 is released. Changes are being made so fast to items legacy Evo users are just getting their head around and we need somewhere we can ask questions (even questions that you may feel are too easy or obvious) without recriminations. Not everyone is a programmer or coding guru.

I am hesitant to ask questions here but we have nowhere else to do it. I read that page on 2.4.0 but it does not make sense to me, I do not understand what it is talking about. It looks like MySQL to my non programming eyes. I know it makes sense to developers, but many Evo users are not programmers, myself included. We need specific examples in the docs, like what you posted in this thread - eg

With these new changes, ordering and flitering like this...
	&orderBy=`pub_date DESC, pagetitle DESC` 
	&filters=`AND(
		content:c.isfolder:is:0;
		content:c.hidemenu:is:0;
		content:c.id:isnot:[*id*];
		blog-archive:is:no
	)`
becomes this...
	&orderBy=`c.pub_date DESC, c.pagetitle DESC` 
	&addWhereList=`c.isfolder=0 AND c.hidemenu=0 AND c.id!=[*id*]`
	&filters=`AND(tvd:blog-archive:is:no)`

There is much reading between the lines needed at the moment which requires a high level of programming expertise

Thanks for the assist.

nick0 commented

also in the DocLister calls...

this works:

	&filters=`AND(tvd:blog-archive:is:no)`

but this version with line spacing and tabs (which worked before 2.4.0) does not:

	&filters=`AND(
		tvd:blog-archive:is:no
	)`

whilst this with tvd removed does:

	&filters=`AND(
		blog-archive:is:no
	)`

Its a little bit quirky.

Full replacement is not needed. These were only general guidelines for using the snippet.

With these new changes, ordering and flitering like this...

&orderBy=`pub_date DESC, pagetitle DESC` 
&filters=`AND(
	content:c.isfolder:is:0;
	content:c.hidemenu:is:0;
	content:c.id:isnot:[*id*];
	blog-archive:is:no
)`

becomes this...

	&orderBy=`c.pub_date DESC, c.pagetitle DESC` 
	&addWhereList=`c.isfolder=0 AND c.hidemenu=0 AND c.id!=[*id*]`
	&filters=`AND(tvd:blog-archive:is:no)`

Both methods are equivalent.

Let's explore how filters work

  • Each filter is a string by rule: <filter type>:<field>:<condition>:<value>
  • Multiple filters are separated by characters ;
  • The end of the filter is considered a character ; or end of line
  • Filter type cannot start with spaces
  • The value can be with spaces and end with them.

Let's take 4 examples as a basis.

  • A1 AND( tv:testA:is:no )
  • B2 AND( tv:testA:is:no)
  • C3 AND( tv:testA:is:no; )
  • D4 AND( tvd:testA:is:no ; tv:testB:is:yes; )

What do we want to get with these filters?

A1 testA="no "
B2 testA="no"
C3 testA="no"
D4 testA="no " AND testB="yes"

Why did it work before with spaces?

Filter parsing started from left to right. But now, right to left. So if you want to use formatting. Do not forget to put a filter separator where your filter ends. For example

&filters=`AND(
	tvd:blog-archive:is:no;
)`
nick0 commented

Thanks for the super clear explanation @AgelxNash.
That's awesome and very much appreciated.
And easy to understand, even for me :)

I was under the impression that previously we needed to keep the ; off the end of the last filter statement. I have remedied that on the site and have a better understanding of usage going forward, thanks. I think perhaps the first issue I had mainly was the missing ; off the last filter statement. Such a little thing.

Thanks again for the easy to understand assist