We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49130
    • 3 Posts
    Hello, I need your help.
    I have folder FAQ and page inside. All pages have TV - input type: listbox(single-select) (input option values). Inside this input option values, I have: Camera||IP Camera||DVR||NVR. I created list used snippet

    <select id="sel" name="cb1">[[!getTvOptions? &tpl=`filterSelectOption` &tvname=`faq` &name=`cb1`]]</select>


    snippet getTvOptions:
    $tv = $modx->getObject('modTemplateVar',array('name'=>$tvname));
    $options = explode('||',$tv->get('elements'));
      
    foreach ($options as $option){
        $opt = explode ('==',$option);
        $ph['value'] = count($opt)>1 ? $opt[1]: $opt[0];
        $ph['text'] = $opt[0];
        $ph['name'] = !empty($asArray) ? $name.'[]' : $name;
        $ph['checked'] = ''; 
        $ph['selected'] = '';
         
        if ((is_array($_REQUEST[$name]) && in_array($ph['value'],$_REQUEST[$name])) || $_REQUEST[$name] == $ph['value']){
     
            $ph['checked'] = 'checked="checked"'; 
            $ph['selected'] = 'selected="selected"';      
            
        }
     
        $output .= $modx->getChunk($tpl,$ph);
    }
      
    return $output;


    chunck filterSelectOption
    <option value="[[+value]]" [[+selected]]>[[+text]]</option>


    When I selected option in listbox I need show pages only with this TV filter (Camera||IP Camera||DVR||NVR)
      • 36996
      • 211 Posts
      You can use getResources with tvFilter - http://rtfm.modx.com/extras/revo/getresources
      I think that tagger is a better option than using tvs for filtering - http://rtfm.modx.com/extras/revo/tagger
        • 49130
        • 3 Posts
        I trid to use getResources but i couldn`t catch selected option.
        [[!getPage@pageLastTplRU? &elementClass=`modSnippet` &element=`getResources` &parents=`1090` &limit=`5` &tpl=`faqTpl` &showHidden=`1` &hideContainers=`1` &includeTVs=`1` &processTVs=`1` &includeContent=`1` &sortby=`publishedon` &processTVs=`1` &sortdir=`DESC` &pageNavVar=`page.nav1` &tvFilters=`faq==[[*cb1]]`  ]]
          • 36996
          • 211 Posts
          What's the value for [[*cb1]]?
          Single value or a list of values?
            • 3749
            • 24,544 Posts
            Filtering by TV values can be very slow, especially if there are many resources. Here is another option, though it can be challenging to implement, depending on your skills:

            http://bobsguides.com/blog.html/2014/06/02/why-extend-modresource/

            http://bobsguides.com/classextender-class.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 49130
              • 3 Posts
              Big thanks for your help)