We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37802
    • 11 Posts
    Yes, TV Panel Title is correct.

    Quote from: markh at Jan 06, 2012, 12:32 AM
    With the modified snippet I tried, I think it should work.

    Is the name (key) of your TV actually "TV Panel Title"? Not the caption, but the name.
      • 37802
      • 11 Posts
      Got it! The list of check boxes is back - I found the wrong ID being referenced in the listMyResources snippet.

      Any idea why the publish check is being ignored when compiling the list of related pages? I tried changing

      'published' => 1,

      to
      'published' => true,

      or
      'published' = '1',

      ...but it made no difference.

      Thanks.
        • 37802
        • 11 Posts
        Also, how would you order the output by TV Page Title?
        I tried re-ordering the resources themselves but it made no difference to the output...I guess it's outputting them as it finds them in the database.
          • 37802
          • 11 Posts
          Thanks again for your help Mark, it's very much appreciated!
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            Either of those published checks should work, MODX is pretty smart at things like that.

            You can't easily change the sort the way it's been coded now (or rather 3 months ago).. alternative method would be to instead of looping over the $ids var, to get a collection of objects (using $modx->getCollection) and using the sortby method on an xPDOQuery.

            Bit too tired to do that now though, sorry tongue

            If you're somewhat good with PHP you can figure it out using this doc: http://rtfm.modx.com/display/xPDO20/Retrieving+Objects (the getCollection and xPDOQuery ones mainly).
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 40131
              • 40 Posts
              Is it possible to modify the parent in multilingual website using Babel, for instance I have 3 contexts...

              @EVAL return $modx->runSnippet('getResources',array('parent' => 18));


              I would like to make it work like this:

              [[BabelTranslation? &resourceId=`18` &contextKey=`[[*context_key]]`]]



              So I would like to take linked-translated parent '18'

              any clues?
                • 40131
                • 40 Posts
                [SOLVED]

                hopefully there is a neat solution - "BabelResourceIdArray" that could be applied in conjunction with getresources

                https://forums.modx.com/thread/51038/babel-a-plugin-for-multilingual-sites-with-revolution

                  • 50574
                  • 70 Posts
                  Hello

                  I'm also using the tutorial and have the same problems as the OP. Following this thread I've been able to get the TVs from various resources to be pulled in but cannot get the checkbox list to show multiple parents. I noticed Zorba had the same problem and resolved it by
                  Got it! The list of check boxes is back - I found the wrong ID being referenced in the listMyResources snippet.
                  but I can only seem to get one of three parents I wish to use to show. I'm sure it'll be something very simple but I can't see what I'm missing?

                  I realise I'm only calling one parent in the listProducts snippet but thought that was just a fallback if it can't find the children of other parents. When I change that parent ID to 4, 5 or 6 the checklist shows the corresponding children but not all three parents together. Does that need to be an array too?

                  Here are my pieces of code:

                  ListProducts Snippet
                  $parent = $modx->getOption('parent',$scriptProperties,5);
                  $parentObj = $modx->getObject('modResource',$parent);
                  if (!($parentObj instanceof modResource)) { return ''; }
                  $resArray = $parentObj->getMany('Children');
                  $resources = array();
                  foreach($resArray as $res) {
                    if ($res instanceof modResource) {
                      $resources[] = $res->get('pagetitle') . '==' . $res->get('id');
                    }
                  }
                  $out = implode("||",$resources);
                  return $out;

                  RelatedProducts snippet
                  if (empty($input)) { return 'This article is so unique, that we couldn\'t find anything related to it!'; }
                  $tpl = $modx->getOption('tpl',$scriptProperties,'relatedProductsTpl');
                  if ($modx->getChunk($tpl) == '') { return 'We found some related pages, but don\'t know how to present it.'; }
                  $ids = explode('||', $input);
                  $output = array();
                  foreach ($ids as $key => $value) {
                    $resource = $modx->getObject('modResource',array(
                      'published' => 1,
                      'id' => $value));
                    if ($resource instanceof modResource) {
                      $ta = $resource->toArray();
                      $tvs = $resource->getTemplateVars();
                      foreach ($tvs as $tv) {
                         $ta[$tv->get('name')] = $tv->get('value');
                      }
                      $output[] = $modx->getChunk($tpl,$ta);
                    }
                  }
                  return implode('',$output);

                  relatedProducts TV input
                  @EVAL return $modx->runSnippet('listProducts',array('parent:IN' => array(4,5,6)));

                  Template snippet
                  [[relatedProducts? &input=`[[*relatedProducts]]` &tpl=`relatedProductsTpl`]]

                  relatedProductTpl chunk
                  <div class="productSliderItem" style="background: url('[[+productBackgroundImage]]') no-repeat; background-size:auto 100%;">
                      <a href="[[~[[+id]]]]" title="[[+pagetitle]]">
                          <div class="shake shake-slow">
                              <img src="[[+productPack]]" />
                          </div>
                          <div class="productSliderTitle">
                              <p>[[+pagetitle]]</p>
                          </div>
                      </a>
                  </div>


                  Thanks in advance [ed. note: cottoncreative last edited this post 9 years, 6 months ago.]
                    • 20648
                    • 26 Posts
                    Hi,
                    I have the same challenge as Cotton.
                    How can I show several parents in the listProducts snippet?

                    Was this question ever answered? If so, I really would like to know.

                    Thanks in advance.
                      • 4172
                      • 5,888 Posts
                      I use migxLoopCollection for lists like that and the @CHUNK - binding

                      @CHUNK inputoptionsProducts
                      


                      in that chunk 'inputoptionsProducts':

                      [[migxLoopCollection?
                      &classname=`modResource`
                      &where=`{"parent:IN":[4,5,6]}`
                      &tpl=`@CODE:[[+pagetitle]]==[[+id]]`
                      &outputSeparator=`||`
                      ]]

                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!