We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47562
    • 113 Posts
    I have a MigX tv, "learn_more_page", loaded up with specific resources in a single-select listbox, with entries provided via:

    [[+pagetitle]]==[[+id]]


    The call to dump the MigX entries in question is:

    [[getImageList? &tvname=`product_info` &processTVs=`0` &tpl=`product_info_item_tpl`]]


    Thought it would be fairly easy to get the value of the listbox selection out to the frontend by adding the following to product_info_item_tpl:

    [[+learn_more_page]]


    But that just puts out a null string.

    Also tried

    [[+tv.learn_more_page]]


    Nothing.

    Can anyone tell me what I should be using in this case? (Ultimately, all I'm trying to do is provide a link to the selected resource in question...).

    Thanks!
      • 4172
      • 5,888 Posts
      again, you can check the db-entries first, by showing the TV-content with:

      [[*product_info]]


      if the value is there, in the json-array,
      as second step you can list the arrays without a tpl with

      [[getImageList? &tvname=`product_info`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 47562
        • 113 Posts
        Quote from: Bruno17 at Jun 15, 2014, 12:35 AM


        [[*product_info]]




        Thanks Bruno.

        When I spit the info out, I see as part of the entry
        "learn_more_page":"10\n"
        Is the newline normal and expected?
          • 4172
          • 5,888 Posts
          no, there shouldn't be a newline.
          How do you fill the input-options?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 47562
            • 113 Posts
            Quote from: Bruno17 at Jun 15, 2014, 10:41 AM
            no, there shouldn't be a newline.
            How do you fill the input-options?

            Ultimately, with a call to getResources.

            Grid columns has:
                {"field":"cp_product_page",
                 "caption":"Product Page",
                 "inputTVtype":"listbox",
                 "inputOptionValues":"@EVAL return $modx->runSnippet('getPageList',array('parents'=>'0','selector'=>'Learn'));"}
            


            Snippet is:
            $parents = (!empty($parents) || $parents === '0') ? explode(',', $parents) : array($modx->resource->get('id'));
            array_walk($parents, 'trim');
            $parents = array_unique($parents);
            
            $selector = (!empty($selector)) ? $selector : 'noop';
            
            $paramsForGetResources = array(
              'parents'=>implode(",", $parents),
              'depth'=>'3',
              'tpl'=>'cp_page_list_info_tpl',
              'includeContent'=>'0',
              'includeTVs'=>'1',
              'showHidden'=>'1',
              'limit'=>'25',
              'sortby'=>'{"menuindex":"ASC"}',
              'outputSeparator'=>'||',
              'includeTVList'=>'cp_page_special_category',
              'tvFilters'=>'cp_page_special_category=='.$selector,
              'debug'=>'1'
            );
            
            $list = $modx->runSnippet('getResources', $paramsForGetResources);
            return $list;
            


            Template is:
            [[+pagetitle]]==[[+id]]
            
              • 4172
              • 5,888 Posts
              may be, you have newline in your tpl-chunk, what happens with:

              $paramsForGetResources = array(
                'parents'=>implode(",", $parents),
                'depth'=>'3',
                'tpl'=>'@INLINE [[+pagetitle]]==[[+id]]',
                'includeContent'=>'0',
                'includeTVs'=>'1',
                'showHidden'=>'1',
                'limit'=>'25',
                'sortby'=>'{"menuindex":"ASC"}',
                'outputSeparator'=>'||',
                'includeTVList'=>'cp_page_special_category',
                'tvFilters'=>'cp_page_special_category=='.$selector,
                'debug'=>'1'
              );
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 47562
                • 113 Posts
                Quote from: Bruno17 at Jun 15, 2014, 01:09 PM
                may be, you have newline in your tpl-chunk, what happens with:

                $paramsForGetResources = array(
                  'parents'=>implode(",", $parents),
                  'depth'=>'3',
                  'tpl'=>'@INLINE [[+pagetitle]]==[[+id]]',
                  'includeContent'=>'0',
                  'includeTVs'=>'1',
                  'showHidden'=>'1',
                  'limit'=>'25',
                  'sortby'=>'{"menuindex":"ASC"}',
                  'outputSeparator'=>'||',
                  'includeTVList'=>'cp_page_special_category',
                  'tvFilters'=>'cp_page_special_category=='.$selector,
                  'debug'=>'1'
                );


                Nope, put the tpl in place as inline and cleared out the cache; still seeing "10\n" for the value. I could just clear out that character I suppose, but I'm now curious where it's getting introduced... smiley