We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28173
    • 409 Posts
    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 ?
      • 3749
      • 24,544 Posts
      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?


        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
        • 28173
        • 409 Posts
        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...
          • 3749
          • 24,544 Posts
          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?
            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
            • 28173
            • 409 Posts
            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 !
              • 3749
              • 24,544 Posts
              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
                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
                • 4385
                • 372 Posts
                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.