We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I us the following call, but the content for Template Variables are not searched...

    How can I make Simple Search also search Template Variables?
    [[!SimpleSearch?
    &tpl=`search_form_row_tpl`
    &perPage=`6`
    &includeTVs=`1`
    &processTVs=`1`
    &containerTpl=`search_form_container_tpl`
    &pageTpl=`search_form_pageTpl`
    &pageNextTpl=`search_form_pageNextTpl`
    &pagePrevTpl=`search_form_pagePrevTpl`
    &currentPageTpl=`search_form_currentPageTpl`
    &pagingSeparator=``
    ]]
    

    This question has been answered by Bruno17. See the first response.

      MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
      DESIGNfromWITHIN, MPThemes and Any Screen Size
      Follow me on Twitter | Read my blog | My code on GitHub
    • Hi Menno,

      Your call looks fine to me. Do you want to show results from a MIGX or a @BINDING value? Because that won't fly as far as i know...

      I'm using a SimpleSearch at the following website with the &includeTVs param as well. Try searching for 'UXRMvehv-6M' (a Youtube ID in a TV) and it will give you the proper result.
      https://www.bercomex.com/nl/zoekresultaten?search=UXRMvehv-6M&id=25
      • Ah than that is it... How can I search MIGX TV's?
          MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
          DESIGNfromWITHIN, MPThemes and Any Screen Size
          Follow me on Twitter | Read my blog | My code on GitHub
        • Quote from: ThaClown at Dec 15, 2015, 10:29 AM
          Ah than that is it... How can I search MIGX TV's?
          You might want to follow this thread for that: http://forums.modx.com/thread/98680/custom-package-contents-and-migx-package-contents-search-using-simplesearch-extra

          But switching to AdvSearch as your weapon of choice might save you some time https://rtfm.modx.com/extras/revo/advsearch
          • Does AdvSearch search MIGX out of the box?
              MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
              DESIGNfromWITHIN, MPThemes and Any Screen Size
              Follow me on Twitter | Read my blog | My code on GitHub
            • Shit AdvSearch does not work for me also... Seems very old and buggy on the latest Revo.
                MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
                DESIGNfromWITHIN, MPThemes and Any Screen Size
                Follow me on Twitter | Read my blog | My code on GitHub
                • 4172
                • 5,888 Posts
                for easier searching, its possible to store the text of all MIGX-items into another 'search-TV'
                with a plugin, that runs at OnDocFormSave.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                • Thank Bruno17 is there a example of this?
                    MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
                    DESIGNfromWITHIN, MPThemes and Any Screen Size
                    Follow me on Twitter | Read my blog | My code on GitHub
                  • discuss.answer
                    • 4172
                    • 5,888 Posts
                    this is one, which I did this days.
                    It is runnung on all resources with given migxtv_templates (3 and 7)
                    It stores all configured Text-fields of configured MIGX-TVs into a target_tv.
                    The target_tv could be at the same resource (if the template matches the given template)
                    or into a child-resource, which matches the given template.
                    This was for a special setup, where some of the MIGX-TVs was not listed at the same resource, but at a child-resource. Normally this option isn't needed.

                    It reads also nested MIGX - TVs, example here, the field 'downloads' with type 'migx' in the migxtv3.

                    <?php
                    
                    $migxtv_templates = '3,7';
                    $config = '[
                    {"tvname":"migxtv","template":"3","target_tv":"searchMigxData","fields":[
                        {"field":"headline"},
                        {"field":"text"}
                    ]},
                    {"tvname":"migxtv","template":"7","target_tv":"searchMigxData","fields":[
                        {"field":"headline"},
                        {"field":"text"}
                    ]},
                    {"tvname":"othermigxtv","template":"4","target_tv":"searchMigxData","fields":[
                        {"field":"headline"},
                        {"field":"text"}
                    ]},
                    {"tvname":"migxtv3","template":"5","target_tv":"searchMigxData","fields":[
                        {"field":"headline"},
                        {"field":"text"},
                        {"field":"headline_bundle"},
                        {"field":"downloads","type":"migx","fields":[
                            {"field":"title1"},
                            {"field":"title2"},
                            {"field":"text"}
                        ]}
                    ]}
                    ]';
                    
                    function jsonFieldsToArray($items, $fields) {
                        global $modx;
                        
                        $output = array();
                        if (!is_array($items)) {
                            $items = $modx->fromJson($items);
                        }
                        if (is_array($items)) {
                            foreach ($items as $item) {
                                foreach ($fields as $field) {
                                    $fieldname = $modx->getOption('field', $field, '');
                                    $type = $modx->getOption('type', $field, '');
                                    if (isset($item[$fieldname])) {
                                        if ($type == 'migx') {
                                            $subitems = $item[$fieldname];
                                            $subfields = $modx->getOption('fields', $field, '');
                                            $suboutput = jsonFieldsToArray($subitems,$subfields);
                                            $output = array_merge($output,$suboutput);  
                                        } else {
                                            $output[] = $item[$fieldname];
                                        }
                                    }
                                }
                            }
                        }
                        return $output;
                    }
                    
                    
                    $migxtv_templates = explode(',', $migxtv_templates);
                    
                    $resource_template = $resource->get('template');
                    if (in_array($resource_template, $migxtv_templates)) {
                    
                        $config = $modx->fromJson($config);
                        foreach ($config as $cfg) {
                            $tvname = $modx->getOption('tvname', $cfg, '');
                            $template = $modx->getOption('template', $cfg, '');
                            $fields = $modx->getOption('fields', $cfg, '');
                            $target_tv = $modx->getOption('target_tv', $cfg, '');
                            $items = $resource->getTVValue($tvname);
                            $values = jsonFieldsToArray($items, $fields);
                            if ($template == $resource_template){
                                //has the template itself - we save to that resource
                                $resource->setTVValue($target_tv,implode("\n\n",$values));
                                
                            }elseif ($target_resource = $modx->getObject('modResource',array('template'=>$template,'parent'=>$resource->get('id')))){
                                //otherwise search child-resource with that template
                                $target_resource->setTVValue($target_tv,implode("\n\n",$values)); 
                            }
                        }
                        
                    }
                    
                    [ed. note: Bruno17 last edited this post 8 years, 2 months ago.]
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                    • Wow that is nice! Thanks Bruno!

                      Damn will have to buy you a beer again... **mumbling whilst clicking the sponsor link**
                        MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
                        DESIGNfromWITHIN, MPThemes and Any Screen Size
                        Follow me on Twitter | Read my blog | My code on GitHub