We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33337
    • 3,975 Posts
    Ditto, 2.1.1 SVN rev1467

    MODx 0961p2 rev 3281

    Error: &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.

    my tpl is:

    [!Ditto? &tpl=`@CODE <li><a href="[~[+id+]~]">[+pagetitle+]</a></li>` &parents=`96,133` &display=`4` &showInMenuOnly=`1`!]

    I used the &debug=`1`, and it shows: tpl @CODE <li><a hre

    Quick help/fix would be appreciated.
    Thank
      Zaigham R - MODX Professional | Skype | Email | Twitter

      Digging the interwebs for #MODX gems and bringing it to you. modx.link
      • 11975
      • 2,542 Posts
      Hi Zi,

      the error comes form the = sign in your html tag.
      This is related to the modx core and the evalSnippet function.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 33337
        • 3,975 Posts
        But its stipping "f" of href as well... so whats the fix? tongue
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 7231
          • 4,205 Posts
          Use a config file to input the data and it should work. Another option is to use a wrapper snippet, but the config file should work. There is an example in the configs folder in assets/snippets/ditto/configs.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 33337
            • 3,975 Posts
            Actually there are many 1 liner templates, so making them in a chunk OR in a config is you know.... tongue so I was finding a shortcut and easy to manage method and @CODE is perfect. But who knew, it just broke! :/
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
              • 11975
              • 2,542 Posts
              There is modified version of the evalSnippet in the forum which fixes this problem.
              Another way would be to change the current ditto code to use Feedx Method for url and change prohibited characters to symbol.
              href|xe| ...

              :-)

                Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                • 11975
                • 2,542 Posts


                // ---------------------------------------------------
                // Function: fetch
                // Get a template, based on version by Doze
                //
                // http://modxcms.com/forums/index.php/topic,5344.msg41096.html#msg41096
                // ---------------------------------------------------
                function fetch($tpl){
                global $modx;
                $template = "";
                if ($modx->getChunk($tpl) != "") {
                $template = $modx->getChunk($tpl);
                } else if(substr($tpl, 0, 6) == "@FILE:") {
                $template = $this->get_file_contents(substr($tpl, 6));
                } else if(substr($tpl, 0, 6) == "@CODE:") {
                $template = substr($tpl, 6);
                //Taken from feedx snippe
                $template =  str_replace(array(’|xq|’,’|xe|’,’|xa|’), array(’?’,’=’,’&’), $template);
                } else if(substr($tpl, 0, 5) == "@FILE") {
                $template = $this->get_file_contents(trim(substr($tpl, 5)));
                } else if(substr($tpl, 0, 5) == "@CODE") {
                $template = trim(substr($tpl, 5));
                //Taken from feedx snippet
                $template =  str_replace(array(’|xq|’,’|xe|’,’|xa|’), array(’?’,’=’,’&’), $template);
                } else {
                $template = $this->language[’missing_placeholders_tpl’];
                }
                return $template;
                }


                You can change the fetch function in class/template.class.inc.php for the above one.

                Hope that helps

                :-)
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 33337
                  • 3,975 Posts
                  Oh thanks for the help guys.

                  I’ll check it out.
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 7231
                    • 4,205 Posts
                    Just in case anyone is looking for where to put the edit above, it is in:
                    assets/snippets/ditto/classes/template.class.inc.php

                    Look into FeedX to see how to use it, basically replace = with |xe| and ? with |xq| and & with |xa|. So the original code would read:
                    &tpl=`@CODE <li><a href|xe|"[~[+id+]~]">[+pagetitle+]</a></li>`

                    It took me a little effort to figure it out laugh
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]