We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    I am stuck on trying to make a custom placeholder. I really don’t "get" how to make an extender.

    What I am trying to do is have a [+details+] placeholder that will pull in the new $_lang[’details’] item I’ve added to the relevant language files, for the "read more..." text before the link. I thought it would be easier to just hack the ditto core, but I’m determined to do it the right way with a custom extender.

    So far everything I’ve tried just completely breaks Ditto (no output at all). :’( :’(
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 11975
      • 2,542 Posts
      Hi Susan,

      could you post the code you wrote ?

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        After much messing around, I ended up with (details.extender.inc.php)
        <?php
        $param = isset($param) ? $param : "default";
        $placeholders['details'] = array($_lang['details']);
        ?>

        and the Ditto call
        [!Ditto? &id=`teaser` &parents=`104` &tpl=`newsTpl` &display=`1` &language=`german` &extenders=`details`!]
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          When I get this figured out I’ll write a Howto in the wiki.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 11975
            • 2,542 Posts
            Could you try with this one.

            I’m sure this is not the nicest way to proceed and Mark will confirm

            but this code should do the trick

            
            <?php
            
            $placeholders['detail'] = array("*","displayDetail");
            if(!function_exists('displayDetail')){
            	function displayDetail($resource){//Not sure if the $resource is needed
            	global $lang;
            	return $lang['detail'];
            	}
            
            }
            
            


            :-)

            EDIT: you’ve been faster than me smiley
            I’ve never written extenders without using the $resource so if you found a different solution , could you post your code.
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Nope, appears that the $_lang array is not available at this point. I also tried including the language file, but it appears that even the $language variable is not available. I’m sure there’s some way of passing it into the extenders facility. At least it didn’t kill the entire Ditto call, though.

              The site has four languages; I could just make four different template chunks, but that’s too easy!
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: sottwell at Jan 07, 2008, 11:50 AM

                Nope, appears that the $_lang array is not available at this point. I also tried including the language file, but it appears that even the $language variable is not available. I’m sure there’s some way of passing it into the extenders facility. At least it didn’t kill the entire Ditto call, though.
                Should be able to access it fine using $GLOBALS[’_lang’][’details’], no?
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  No.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Ah, right, only in the manager; try adding...
                    $_lang = array();
                    to the index.php somewhere before the executeParser() call.
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      No. err.... no execute Parser call in manager/index.php??
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org