We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41294
    • 34 Posts
    I want to have a single select List Box TV with dynamic options based on Input Option. On every parent resource, there's a MIGX setup for categories and the List Box TV should be pulling from it and assign it to its child resources.

    Let say the structure shows like this:

    -Parent 1 (5)
    --Child 1
    --Child 2
    -Parent 2 (6)
    --Child 1
    --Child 2
    


    so the single select List Box TV would be assigned to all children whatever the parent may be. Every parent have MIGX setup for categories for its child resources. Let say above i have 2 Parent resources with IDs 5 and 6 respectively. Is it possible to retrieve those parent ID using @EVAL inside TV Input Option?

    My code inside Input Option is like this:

    @EVAL $output = $modx->runSnippet('getImageList',array('tvname'=>'article_categories','limit'=>'0','docid'=> '5','tpl'=>'categories_option_tpl','outputSeparator'=>'||'));return $output;


    As you can see 'docid' is pointing to ID '5' w/c is not dynamic at all. I want it to be dynamic to whatever the child resource that TV assigned to. Code would be something like this (but this code doesn't work):

    @EVAL $output = $modx->runSnippet('getImageList',array('tvname'=>'article_categories','limit'=>'0','docid'=> '$modx->resource->get('parent');','tpl'=>'categories_option_tpl','outputSeparator'=>'||'));return $output;


    'docid' value is '$modx->resource->get('parent');' to pull the parent ID whatever the child resource is, but this doesn't work. But that should be the logic.

    Any ideas?

    Thanks smiley
      • 4172
      • 5,888 Posts
      not sure, if $modx->resource is avail here and what happens on a new resource.
      If so, than try:

      @EVAL $output = $modx->runSnippet('getImageList',array('tvname'=>'article_categories','limit'=>'0','docid'=> $modx->resource->get('parent'),'tpl'=>'categories_option_tpl','outputSeparator'=>'||'));return $output;
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 41294
        • 34 Posts
        I thought i already tried that approach but it turns out i put a semi-colon at the end that's why it didn't work and now it's working great!

        Thanks Bruno17 smiley
          • 46404
          • 5 Posts
          snippet (parent_title)
          <?php
          // (c) badichan.com
          $page = $modx->getObject('modResource', $input);
          $id = $page->get('parent');
          $parent_page = $modx->getObject('modResource', $id);
          echo $parent_page->get('pagetitle');
          ?>
          chunk
          [[!parent_title? &input=`[[*parent]]`]] [ed. note: badichan last edited this post 12 years, 8 months ago.]