We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37213
    • 25 Posts
    Hi I try to play with XPDO, but seem I miss something to call my result, is there someone can help me on the right direction thanks.

    Got result in my phpadmin from this sql query:
    Select modx_site_tmplvar_contentvalues.value
    FROM modx_site_content INNER JOIN modx_site_tmplvar_contentvalues on modx_site_content.id = modx_site_tmplvar_contentvalues.contentid
    WHERE modx_site_content.parent= '100' and modx_site_tmplvar_contentvalues.tmplvarid = 333
    ORDER BY cast(modx_site_tmplvar_contentvalues.value AS SIGNED) DESC
    
    try to do this, but without result. 
    $c = $modx->newQuery('modResource');
    $c->innerJoin('modTemplateVarResource', 'TemplateVar', 'TemplateVar.contentid = modResource.id');
    $c->where(array('modResource.parent' => 100, 'TemplateVar.tmplvarid' => 333)); 
    $c->limit(5);
    $c->sortby("CAST(TemplateVar.value AS SIGNED)", 'DESC');
    
    [ed. note: viewsonic last edited this post 14 years, 8 months ago.]
      • 3548
      • 102 Posts
      That code is OK. What do you mean without result?
        Antonio Zdilar
        linearvector.com
        • 3749
        • 24,544 Posts
        I'm not sure if your code example is complete, but you need a getCollection() call (or something similar) to actually query the DB and you need to create and return some output so there's something to display:

        <?php
        $resources = $modx->getCollection('modResource', $c);
        
        $output = '';
        foreach ($resources as $resource) {
            $output .= '<br />TITLE: ' . $resource->get('pagetitle');
        }
        return $output;



        ---------------------------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
        MODx info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 37213
          • 25 Posts
          Hi Guys thanks for your help, everything is working well...

          BobRay thanks for your example, that give me to the right direction. I thought my xpdo was wrong, seem it was my code.

          have a nice day guys.
            • 3749
            • 24,544 Posts
            I'm glad you got it sorted. Thanks for reporting back. smiley



            ---------------------------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
            MODx info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting