We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20765
    • 90 Posts
    myfriendscallmebill Reply #1, 19 years, 6 months ago
    I get the impression that the "request" extender somehow lets me change the behavior of a Ditto call by appending modifiers to the URL that invokes the web page. Is that anywhere near right?

    And in any case, how do I use it? How to I form URLs? What are my options? I’ve read the docs, which give cryptic descriptions of the three parameters it adds to Ditto, but I can’t intuit from them how to use this feature.
      • 18397
      • 3,250 Posts
      Exactly. Once you add &extenders=`request` to your Ditto call you can change Ditto params on the fly using ditto_paramName in either the URL or passed as a post variable. Note that if you have a Ditto ID set it would be ditto_ID_paramName. So to summarize 4 docs you would add &ditto_summarize=4 to the URL and volia!

      You have the following parameters to control:

      &good (in SVN) - Parameters that you want to allow, defaults to all other than &bad
      &bad - Parameters you want to disallow
      &stripTags - remove all tags (MODx and HTML)
      &dbg (via post or get) - Show the variables set by the extender
        • 8454
        • 55 Posts
        A latecomer: I would be immensely grateful i you could specify slightly, I am new to MODx.

        I need to pass the pagetitle of the page I am coming from (where Ditto is called) to be used building a Ditto rendered menu in the page I am going to.
        What would the code look like and where to put it?
          • 36416
          • 589 Posts
          Quote from: eddygrove at May 07, 2009, 06:02 PM

          I need to pass the pagetitle of the page I am coming from (where Ditto is called) to be used building a Ditto rendered menu in the page I am going to. What would the code look like and where to put it?

          Take a look at the following demo:
          /snippets/ditto/extenders/example.extender.inc.php

          its almost exactly what you want...
            • 8454
            • 55 Posts
            Thanks a lot, Eol, for answering in this old thread!

            Thing is, I am yet totally lost in the world of php, I can’t "read" that file, honestly. I don’t understand how it is combined with a Ditto call. I can’t even judge if it would be asking for to much if I need concrete example code.

            In a menu I have:
            [!Ditto? &parents=`56` &filter=`[%LANG%]ProductGroup,[*[%lang%]pagetitle*],7` &tpl=`ColumnItem` &tplCurrentDocument=`CurrentColumnItem` &extenders=`request` !]

            where ProductGroup is a TV whose value may or may not correspond to the pagetitle where the links to the documents are diplayed and ColumnItem obviuosly is a chunk, goes
                <div class="ditto_item" id="ditto_item_[+id+]">
            <div><img src="[+mainimage+]"></div>
                    <h3 class="ditto_pageTitle"><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
                </div>
            

            when I click a one of the links thus construed, I go to a new page and the pagetitle changes, but I want the menu (still showing) to stay intact, I need to pass the recent pagetitle to the new page. That way I could filter with:
            &filter=`[%LANG%]ProductGroup,[*[%lang%]thePassedValue*],7`

            or something similar.
            What would the Ditto calls in the starting and landing pages respectively look like to accomplish that, and is anything else needed?
            Any example would be of help!
              • 36416
              • 589 Posts
              Quote from: eddygrove at May 11, 2009, 05:11 PM

              when I click a one of the links thus construed, I go to a new page and the pagetitle changes, but I want the menu (still showing) to stay intact, I need to pass the recent pagetitle to the new page. That way I could filter with:
              &filter=`[%LANG%]ProductGroup,[*[%lang%]thePassedValue*],7`

              or something similar.

              Uh, this whole parameter chaining is making me dizzy... what are [%%] values, certainly not MODx tags?

              Here is an idea - pass DocumentID from one page to another by URL:
              <a href="[~[+id+]~]?fromid=[*id*]">[+pagetitle+]</a></h3>

              and then modify filter criteria by snippet that picks desired value from request
              $_GET['fromid'] ...
                • 8454
                • 55 Posts
                Thanks Eol, now I am almost there!

                Dizzy is the word...the [%lang%] values are for a snippet called EasyLingual, that I just learned, was merely showing off wink
                No, seriously I should have used a stripped example.
                The parameter chain is the clause for Dittos &filter parameter, and says "exclude documents whose TV ProductGroup does not contain the pagetitle" in the first page and my idea was to use it to "exclude documents whose TV ProductGroup does not contain thePassedVariable (i.e. the previous pagetitle)" in the landing page. (Which you certainly know already, but for anyone new to Ditto it might be clearer).
                Quote from: Eol at May 12, 2009, 04:20 PM

                Here is an idea - pass DocumentID from one page to another by URL:
                <a href="[~[+id+]~]?fromid=[*id*]">[+pagetitle+]</a></h3>

                Yes! Your chunk above was just what needed, I only changed the ?fromid to &fromid (well, actually &frompage in my case, since I want the pagetitle), then it worked. I can now see the output in the URL: //localhost:8888/modx/index.php?id=60&frompage=Pouches

                Now I only need to get it into the Ditto call on the landing page.
                Could you PLEASE, PLEASE type the whole call, I am so close to the goal now... tried with:
                [!Ditto? &parents=`56` &filter=`ProductGroup,$_GET['frompage'],7` &tpl=`ColumnItem` &tplCurrentDocument=`CurrentColumnItem` !]

                Didn’t display any documents at all, which the starting page did.
                Then I tried with
                [!Ditto? &parents=`56` &filter=`enProductGroup,[[Frompage]],7` &tpl=`ColumnItem` &tplCurrentDocument=`CurrentColumnItem`!]

                and a snippet Frompage with the following:
                <?php
                $_GET['frompage']
                ?>

                Gives a parse error, propably stupid to even try nesting a snippet in a parameter, or what? D’oh! Told you I’m lost...
                  • 4172
                  • 5,888 Posts
                  try:
                  <?php
                  return $_GET['frompage'];
                  ?>
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 8454
                    • 55 Posts
                    Yes! It works. I love this community. When I grow up, I also wanna drop php-oneliners and save some poor bastard’s day...(more like month)

                    OK, so all this is dead simple for someone who knows php, passing variables via URL. I needed it for products belonging to multiple groups in a catalog, eventually e-commerce site, where a plain document tree and Wayfinder wont do.
                    Will it look amateurish or even be potentially unsafe to show variable passing in the URL in a live site? Would you see this kind of solution in TreasureChest, Kiwee or Magento do you think?

                    Thank you so much for your input!
                      • 16278
                      • 928 Posts
                      If you put some of your Ditto parameters into a config file stored as /ditto/configs/myparameters.config.php, you can include the GET retrieval very simply, e.g.
                      [!Ditto? &parents=`56` &config=`myparameters`!]

                      and the contents of myparameters.config.php:
                      <?php
                      $filter=’ProductGroup,’ . $_GET[’frompage’] . ’,7’;
                      $tpl=’ColumnItem’;
                      $tplCurrentDocument=’CurrentColumnItem’;
                      ?>
                      Tidier and easier to maintain than an extra mini-snippet. Just have to remember to change all the & to $ and all the back-apostrophes to normal ones if copy & pasting shocked
                      KP