We launched new forums in March 2019β€”join us there. In a hurry for help with your website? Get Help Now!
    • 17422
    • 225 Posts
    via a snippet, I want to know the position of a resource in a folder, whether it’s the first or last resort or if this position

    ex : in folder i have a ressource : 12,25,14,8,47,42

    i want to know the ids which are after and before the id 8


    with modx revo
      • 17422
      • 225 Posts
      i found :

      with the snippet getChildcount and with getResourceField

      <?php
      $count = 0;
      $parent = isset($parent) ? (integer) $parent : 0;
      if ($parent > 0) {
          $criteria = array(
              'parent' => $parent,
              'deleted' => false,
              'published' => true,
          );
          $count = $modx->getCount('modResource', $criteria);
      }
        $field='menuindex';
        $criteria = $modx->newQuery('modResource');
        $criteria->select($modx->getSelectColumns('modResource','modResource','',array('id',$field)));
        $criteria->where(array('id'=>$id,));
        $resource = $modx->getObject('modResource',$criteria);
        $fieldValue = $resource->get($field);
        $output = $fieldValue;
        
          return (string) $count.'_'.$output;​