We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20364
    • 89 Posts
    This is so basic and is just simply not working, and I cannot figure out why.

    Snippet MakeUrl:

    return $modx->makeUrl($id);

    Pretty straightforward ... here is the call:

    [[MakeUrl?id=[[+clientlogo_showcase]]]]

    [[+clientlogo_showcase]] is an integer. When I make the call, it returns nothing. Now for the weird part ..

    If I change snippet MakeUrl to simply "return $id", it returns it with no problem, so it’s certainly passing the number properly.

    If I change the call to [[MakeUrl?id=3]], it returns the Url with no problem.

    Any idea what could possibly be causing this?
      • 28215
      • 4,149 Posts
      Why dont you just do:

      [[~[[+clientlogo_showcase]]]]
      


      ?
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 20364
        • 89 Posts
        Because I have been coding for 10 hours straight and that just makes too much sense wink

        That said - it still doesn’t work, so obviously even though it appears to be a valid int that is being returned from the snippet, it is apparently not.

        Here is the snippet:

        <?php
        $doc = isset($doc) ? $doc : 0;
        $depth = isset($depth) ? $depth: 100;
        if(!function_exists("getItems"))
        {
        function getItems($p=0, $d=100, $l=0)
        {
        global $modx,$modx_charset;
        ($modx_charset==’UTF-8’) ? $nbsp=chr(0xC2).chr(0xA0) : $nbsp=chr(0xA0);
        $c=$modx->getDocumentChildren($p);
        foreach($c as $k)
        {
        $out.=str_repeat($nbsp,$l*5).$k[’pagetitle’]."==".$k[’id’]."||";
        if($l<$d) $out.=getItems($k[’id’],$d,$l+1);
        }
        return $out;
        }
        }
        return getItems($doc,$depth);
        ?>

        This is set to a TV via:

        @EVAL return $modx->runSnippet("getChildDocuments",array(’doc’=>17,’depth’=>0));

        As a single-select list box. This works like a charm, and outputs the ID of the selected doc, which I am then passing as

        [[~[[+clientlogo_showcase]]]]

        which is outputting nothing sad
          • 28215
          • 4,149 Posts
          So clientlogo_showcase is a TV?

          If so, shouldn’t it be:

          [[~[[*clientlogo_showcase]]]]
          
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 20364
            • 89 Posts
            Sorry, I should have stated this is inside a Wayfinder call, so it turns in to a placeholder. When I just put the placeholder call, it does output the proper integer, so that isn’t the issue, so it seems.
              • 3749
              • 24,544 Posts

              I would put an ampersand on the parameter, add some back-ticks, and I wouldn’t used "id" as a parameter name.

              [[MakeUrl? &MyId=`[[+clientlogo_showcase]]`]]

                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
                • 20364
                • 89 Posts
                Is good advice, however even the call from above doesn’t work:

                [[~[[+clientlogo_showcase]]]]

                so unfortunately it isn’t in the snippet call
                  • 3749
                  • 24,544 Posts
                  I’m not completely clear on what you’re doing, but it looks like a parsing order problem. Possibly the placeholder tag is in the Wayfinder tag, but when that Wayfinder tag is parsed, Wayfinder hasn’t set the placeholder yet.
                    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
                    • 20364
                    • 89 Posts
                    Ignoring all of the jumbo about [[MakeUrl]] above ... essentially here is what is happening:

                    In Wayfinder, TVs "change" to placeholders per the element that it is repeating for the menu.

                    I have a TV called clientlogo_showcase that is a single select list, pulled via the @EVAL I pasted above, which essentially grabs the children elements under a document by ID. So end of the day, clientlogo_showcase is a single ID.

                    In the Wayfinder call, when I only put [[+clientlogo_showcase]], it outputs the ID properly. When I change the call to [[~[[+clientlogo_showcase]]]] (as I need it to be the url path), it returns nothing.

                    Here is how the value looks in the database:



                    So essentially, the call SHOULD be [[~95]] ...
                      • 20364
                      • 89 Posts
                      Can’t figure out why ... but it seems the root of the problem is passing placeholders in Wayfinder.

                      I can’t for the life of me find the logic in this ... it appears this is what is happening:

                      - Wayfinder rowTpl passes data contained in a placeholder to a Snippet
                      - IF the Snippet simply echos the value, it works
                      - IF the Snippet tries to do any function on the value, it returns null

                      same with if you pass it to something like [[~xx]]

                      - If [[+myId]] is 95
                      - In the Wayfinder rowTpl, [[+myId]] outputs "95"
                      - In the Wayfinder rowTpl, [[~[[+myId]]]] outputs ""

                      I am stumped sad