We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50923
    • 137 Posts
    Getting id of current edited resource in manager is that possible, I have some TV that get all id from resources like this

    @SELECT pagetitle, id FROM modx_site_content WHERE parent=7


    The only problem i dont need to be hardcoded 7, i need there to be id of current edited resource in manager?

    Like this does not work

    @SELECT pagetitle, id FROM modx_site_content WHERE parent=[[*id]]
      <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
      • 50923
      • 137 Posts
      I have tried like this

      <?php
      $children = $modx->resource->getMany('Children');
        $output = '';
         
        $list = array();
        foreach($children as $child)
        {
      //check if correct template
          if($child->get('published')&&$child->get('template')==21)
          {
            $list[]  = $child->get('pagetitle').'=='.$child->get('id');
          }
        }
         
        $output .= implode('||',$list);
         
        return $output;


      But the problem is that only return first ID in TV on frontend returns full value like this

      Brzi recepti==14||Predjela==12 
        <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
        • 36926
        • 701 Posts
        Quote from: miomir.dancevic at Apr 03, 2017, 06:48 AM
        I have tried like this

        <!--?php
        $children = $modx--->resource->getMany('Children');
          $output = '';
           
          $list = array();
          foreach($children as $child)
          {
        //check if correct template
            if($child->get('published')&&$child->get('template')==21)
            {
              $list[]  = $child->get('pagetitle').'=='.$child->get('id');
            }
          }
           
          $output .= implode('||',$list);
           
          return $output;


        But the problem is that only return first ID in TV on frontend returns full value like this

        Brzi recepti==14||Predjela==12 

        Instead of using @select, run that snippet with
        @EVAL return $modx->runSnippet('yourSnippetName');
        
          • 50923
          • 137 Posts
          I have tried but i only got 14, and first empty
            <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
            • 36926
            • 701 Posts
            Quote from: miomir.dancevic at Apr 03, 2017, 09:51 AM
            I have tried but i only got 14, and first empty

            Just tried with your snippet but without the if statement for published and template and it's working fine for me.