We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19156
    • 8 Posts
    Hi

    I’m working on this snippet that lists the content of a folder as small images. Can anybody tell how to make this order the documents by "Menuindex"? Im stuck.

    It looks like this:


    // Usage:
    // [[ContentListing?id=0]]
    //

    $content = "";
    $root = $modx->getDocument($id , ’description’);
    $content .= $root[’pagetitle’]."";
    $content .= "";

    function getContent($id, $modx) {

    $children = $modx->getActiveChildren($id,’pagetitle’,’ASC’,’id, pagetitle, description, isfolder’);

    $output = "<ul class=’bot’>\n";

    foreach ($children as $child) {


    if($child[’id’]==$modx->documentIdentifier) {
    $active="img src=’thumbs/firkant.gif’ border=’0’";
    } else {
    $active="img src=’thumbs/firkantHover.gif’ border=’0’";
    }

    if ($child[’description’]!="") {

    $output .= "<li class=’botli’>";
    $output .= "<a href=’index.php?id=".$child[’id’]."’><".$active.">".$child[’’]."</a>";



    $output .="</li>\n";

    } else {
    $output .= "<li class=’botlito’>";
    $output .= "<a href=’index.php?id=".$child[’id’]."’><img src=’thumbs/firkant.gif’border=’0’>".$child[’’]."</a>";

    if ($child[’description’]!="") {
    $output .= " - ".$child[’’];
    }

    $output .= "</li>\n";
    $output .= getContent($child[’id’], $modx);

    }


    }


    $output .= "</ul>";
    return $output;
    }

    $content .= getContent($id, $modx);


    return $content; //udskriv
      • 4041
      • 788 Posts
      change it here (pagetitle) in this line of the code:

      $children = $modx->getActiveChildren($id,’pagetitle’,’ASC’,’id, pagetitle, description, isfolder’);
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 19156
        • 8 Posts
        Thanks! Now it works!