• XPDO problem#

  • viewsonic Reply #1, 3 months, 2 weeks ago

    Reply
    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');
    


  • blankcheck Reply #2, 3 months, 2 weeks ago

    Reply
    That code is OK. What do you mean without result?


  • BobRay Reply #3, 3 months, 2 weeks ago

    Reply
    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


  • viewsonic Reply #4, 3 months, 2 weeks ago

    Reply
    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.


  • BobRay Reply #5, 3 months, 2 weeks ago

    Reply
    I'm glad you got it sorted. Thanks for reporting back.


    ---------------------------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
    MODx info for everyone: http://bobsguides.com/modx.html