Very often you have to solve the standart tasks. MODx Evo / Revo db API can let us build our code fatser and safer.

The following php code returns the child resources ids of the parent doc in MODX Evolution:

  1. <?php
  2. $ret = '';
  3.    $return = array();
  4.    $table_name = $modx->getFullTableName( 'site_content' );
  5.    $ChildResIds = $modx->db->select('id', $table_name , "parent = $parent");
  6.    $Rows = $modx->db->getRecordCount( $ChildResIds );
  7.    if($Rows > 0){
  8.      while($row = $modx->db->getRow( $ChildResIds )){
  9.         $return[] = $row['id'];
  10.      }
  11.    }
  12.  
  13. $ret = implode(",", $return);
  14. return $ret;
  15. ?>

The following XPDOphp code returns the child resources ids of the parent doc in MODX Revolution:

  1. $resources = $modx->getCollection(“modResource”, array(“parent” => 3,“context_key” => “web”));


Rate this information:
  • Currently2.9842931937173/5 Stars
  • 1
  • 2
  • 3
  • 4
  • 5
Votes: 2101

May we recommend:
taxi organisation website on modx evo  Web-based inventory scan app  psd to html and html to modx template  Link pruning, Fix Crawl Errors  

MODX CMS extensions Sale:

5h support  MODX Evolution documents as products export to google base  3h support  6h support  


Modx Extras for advanced content