We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17866
    • 3 Posts
    Can someone please describe how to join resources(documents, folders) using leftJoin, i can’t find any non abstract info on that topic.

    Site structure:

    Blog
    ->Games(folder as category)
    -->Left4Dead2(resource as blog post)
    -->GTA4
    -->Unreal 3

    I just want to output latest posts with categories on the frontpage, so i wrote a snippet like so:

    
    $query = $modx->newQuery('modResource');
    
    //$query->leftJoin(....
    
    
    $query->where(array(
    
        'published' => 1,
        'isfolder'  => 0
    
    ));
    
    
    $query->limit(5);
    $query->sortby('id','DESC');  
    
    $items = $modx->getCollection('modResource', $query);
    
    
    foreach($items as $item)
    {
    
        echo $modx->getChunk('Post', array(
    
            'cat'           => 'Category title here...',
            'cat_href'      => $modx->makeUrl($item->get('parent')),
    
            'subject'       => $item->get('pagetitle'),
            'subject_href'  => $modx->makeUrl($item->get('id')),
    
            'content'       => $item->get('introtext'),
    
            'comments'      => 'Comment count goes here...'
    
        ));
    
    }


    I just can’t understand how join works. huh
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Uhm. Why do you need join?

      You could just use getResources with the parent IDs of your categories, and reference the parent (=category) in the tpl with [[+parent]]?


      Maybe I’m not understanding what you need.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.