We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36633
    • 1 Posts
    I just wanted to contribute this work in progress. I decided to use MODx for a project I'm working on that involves using WIMP (Windows IIS MySQL PHP) to run a local version of MODx to generate static pages to be uploaded to a remote web server. While the remote server is LAMP, for the purposes of our project I needed to just have everything flat/static on the remote server.

    I use the convention of having MODx name the pages by their aliases (great feature!), and I wanted a simple blogging type capability whereby I have a parent page that has a snippet that will list all of the child pages by title, linked of course to the pages themselves. I can make new posts on the local machine and then have them autoupload to the server as soon as I export static html the next time.

    Now, I know there may be like four other people out there doing things this way, and I know that there are probably countless other more correct ways to do this, but it works great for me:

    <?php
    /*
    * Statickidz snippet by DJWJ at codeanimals.com
    * This is a snippet for people who use MODx to generate static pages to be uploaded to a server
    * using the convention of naming the pages by their aliases. The snippet can be inlcuded with no parameters
    * on, for instance, the main parent page template of a simplified blog. If you create pages below this parent page, and then
    * add the [[*Statickidz*]] snippet call you will get a hyperlinked list of the children pages' pagetitles, with the links being absolute
    * such as 'http://www.yoursitename.com/somepagesalias.html.
    *
    *Note that you need to change the base string to your site's name.
    *Note that we are using absolute links because that breaks a lot of the more simple unauthorized site mirrors that we're seeing lately
    * ... but feel free to change the baseString to relative links
    *
    *This snippet is based on Jason Coward's and Ryan Thrash's much more elegant FirstChildRedirect snippet
    */

    $docid = (isset($docid))? $docid: $modx->documentIdentifier;
    $baseString = '<a href=http://www.yoursitenamegoeshere.com/';
    $finLinkString = '.html>';

    $children= $modx->getActiveChildren($docid, 'menuindex', 'ASC');
    if (!$children === false)
    {
    foreach($children as $kid)
    {

    $returnString .= $baseString;
    $kidUrl= $kid['alias'];
    $kidTitle= $kid['pagetitle'];
    $returnString .= $kidUrl. $finLinkString . $kidTitle . '</a>
    ';
    }
    }
    else
    {
    $returnString = "No posts to display";
    }

    return $returnString ;
    ?>