⚠️ Urgent! Active Attacks on MODX Revolution Sites Below Revolution 2.6.5
Subscribe: RSS
  • I'm blocked with a very stupid thing...
    I have a Collections view with a resource's ID column.
    I want to render those IDs with their respective pagetitle.
    So I create a snippet called getPagetitleFromID which I call from the Snippet columns view parameter.

    But I don't know how to make this snippet code.
    I read a little bit xPDO docs but I was a little bit affraid !!!

    For now, I have just wrote this but it doesn't work :
    $value = $modx->resource->getOne('value');
    return $value->get('pagetitle');


    Is anyone can help me ?
    • Is there a Tpl for the display? If so, try putting this tag in it:

      [[+pagetitle]]


      If that doesn't work, how are you sending the ID to your snippet?


        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
      • Quote from: BobRay at May 15, 2018, 03:56 AM
        Is there a Tpl for the display?
        No, I don't have template !
        Just a snippet code with php.

        If that doesn't work, how are you sending the ID to your snippet?
        That's the point !
        On this blog post about Collections, there is an interesting section about "Image and other Custom Renderers"
        But I not very competent with JS nor Php, so I'm a little bit lost...
        • Sorry, I'm still not clear on what your trying to do. Are you trying to show a list of resources in the front end with getResources or pdoResources?
            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
          • Sorry I was not clear on my first post...

            Here my Collection view :

            You can see on the second column a number : it's the ID to a resource retreived from a list of Categories.
            I want to get the categorie's pagetitle instead of the ID

            On the collection column settings , I can set a snippet to render the result :



            So I create a snippet called getPagetitleFromID because it's look the best way to get what I want.
            But I have difficulties to write the code of this snippet !
            • I think there's a Columns section on the Collection's Settings tab that give you the option of altering existing columns or adding new ones. I'm not sure how it works.

              See the Columns section here: https://docs.modx.com/extras/revo/collections
                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
              • Came here looking for the answer. Ended up making it myself.

                <?php
                $resourceID = $modx->getOption('value', $scriptProperties, '');
                $resource = $modx->getObject('modResource', $resourceID);
                $output = $resource->get('pagetitle');
                return $output;
                
                  DropboxUploader -- Upload files to a Dropbox account.
                  DIG -- Dynamic Image Generator
                  gus -- Google URL Shortener
                  makeQR -- Uses google chart api to make QR codes.
                  MODxTweeter -- Update your twitter status on publish.