We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20912
    • 21 Posts
    Hello everybody! I have a question to you all!
    This is considering multiple tvFilter.
    Goal: To be able to sort resources by certain criteria.
    Realization:
    - I have resources with certain template. For instance news.
    - I have a list pf authors wich should be matched with news. One author can write few news. In order to achieve it. I created different template "author", set tv (checkbox, delimenter ’,’, ) for this template "author-news", and receiving the list of values:
    @SELECT `pagetitle` AS `name`,`id` FROM `[[+PREFIX]]site_content` WHERE `template` IN(5). Afterwards when we creates authors we can align author with its news by selecting his news in tv, furthermore because we created checkbox type we can select few news simultaneously, to separate them we creating output type as delimiter. output something like: 1,12,15,150. everything clear and easy till this moment.
    - nest step is to list all document in front-end and to be able to filter them. Solution for this is quite easy:
    filter:
    [[!Wayfinder?
    &startId=`10`
    &level=`10`
    &rowTpl=`trainer-filter`
    &includeDocs=`[[getResources? &parents=`10` &where=`{"template:IN":[5]}` &tpl=`simpleID` &tplLast=`simpleID-last` &depth=`100` &limit=`0`]]`
    ]]
    chunk "trainer-filter": <li><a href="[[~65? &filter=`[[+wf.docid]]`]]" [[+wf.attributes]]>[[+wf.linktext]][[+wf.wrapper]]</a></li>

    output:
    [[!getPage?
    &elementClass=`modSnippet`
    &element=`getResources`
    &parents=`[[*id]]`
    &includeTVs=`1`
    &where=`{"template:=":13}`
    &tvFilters=`author-news==%[[!getUrlParam? &name=`filter` &int=`1`]]%`
    &includeContent=`1`
    &tpl=`trainer`
    ]]

    important line:&tvFilters=`author-news==%[[!getUrlParam? &name=`filter` &int=`1`]]%` as you can see this line gets GET parameter in url (ex. mysitename.com/news/news1.html?filter=15) and receives only news to which author id 15 is aligned. in order to inquire specific id out of the line of all ids (ex. 1,12,15,150) we use wildcard % in &tvFilters getResouces parameter. as result everything is filtering quite well, but there is one problem.

    PROBLEM: Because we use wild card to inquire tvs we are selecting all tvs with specifig values. So if the value is 15, 150 and 1500 is also considering as right values. or if value is on 5, then all numbers with 5 (like 15, 25, 55) are satisfied to this filter.

    Question. How to change this idea in order to fix this problem?
    Related topic and solution is http://modxcms.com/forums/index.php/topic,62876.msg356482.html#msg356482, but because my values are generated by @select, I can not change it, or can I?