We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22164
    • 50 Posts
    Please excuse me if the question is stupid, but I spent the good deal of today trying to figure this out and just do not seem to get past the problem mentioned below.

    I did look at the modxwiki and managed to get the rss feed working for a particular page like on http://www.rugpijnweg.nl/rugpijnweg-feed.html

    On the modx blog I see two buttons below posts: one for the permalink and one for the rss feed of that page.

    The permalink I have been able to make using a chunk.

    My trouble is in replicating the rss feed for each page, on the modx blog I see it is a dynamic link to a page, par example
    http://modxcms.com/feed.xml.html?id=263

    Two questions:
    1- how can I get this to be dynamic, so it shows the feed connected with each particular post page in the link - preferably with rss feed logo
    2- how do I have to code the receiving page so it reads the ?id=whatever the number may be and shows the correct feed?

    thanks

    OliverF
      Happy to have left Back Pain | Sciatica behind.
      • 7231
      • 4,205 Posts
      You will need to add some logic to a wrapper or support snippet to get the value from the URL then use that parameter in the snippet call for parents. Basically returning the $_GET[’cat’] value and using it for the parents parameter (don’t forget to add a default and some validation like checking if it is a number).

      Ditto actually has built in capabilities for this (I always forget). You need to look into the request extender to do this directly in ditto.
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 22164
        • 50 Posts
        Thanks for that, I looked at requestextender but that does not show me how it is done, only that it can be done. Maybe it does show it, but I do not see it.

        I am a copy paste person so if you or someone else could post some working code then I am sure I would be able to get it going.

        thanks for taking time though, it is a step forward again.

        OliverF
          Happy to have left Back Pain | Sciatica behind.
          • 10449
          • 956 Posts
          // edit: sorry, I guess I shouldn’t post when i’m tired. I was basically just repeating what dev_cw already posted (minus the request ext. stuff)...


          1- how can I get this to be dynamic, so it shows the feed connected with each particular post page in the link - preferably with rss feed logo

          I’m not sure I understand... A feed for a single blog-post? That doesn’t make sense. You normally either create a feed per category (that might be just a separate modx-container), or a feed per author. Or maybe even something fancy like a filtered feed: only show entires tagged with "foo".

          Change the Ditto RSS call so it accepts the parent parameter via query string (assuming each blog category is in its own folder).

          e.g. prepend a snippet:

          <?php
          $defaultParent = 10; // default parent id if nothing else is defined
          if($_GET["blogCatID"]) {
              $defaultParent = (int) $_GET["blogCatID"];
          }
          
          $modx->setPlaceholder("dittoRSSParent", $defaultParent);
          
          ?>
          

          Then you can change your RSS Ditto call to include the placeholder:
          [!Ditto? &parents=`[+dittoRSSParent+]` ...!]


          Other methods would just use the parent placeholder, or UltimateParent snippet to dynamically fetch the parent folder id.
          <a href="[~rssdocid~]&blogCatID=[*parent*]">rss feed</a> // example link in a blog post page...



            • 22164
            • 50 Posts
            Thanks, I tried the following, cause I do not know what prepending a snippet means.

            I dropped all of the following in the page that is supposed to give me the feed.
            <?php
            $defaultParent = 10; // default parent id if nothing else is defined
            if($_GET["blogCatID"]) {
            &#160; &#160; $defaultParent = (int) $_GET["blogCatID"];
            }

            $modx->setPlaceholder("dittoRSSParent", $defaultParent);

            ?>
            [[Ditto? &parents=`[+dittoRSSParent+]` &format=`rss` &summarize=`10` &total=`10`]]

            And then I get the following message:
            XML-parsefout: XML- of tekstdeclaratie niet aan begin van entiteit
            Locatie: http://www.rugpijnweg.nl/rugpijnweg-feed.html?&manprev=z
            Regelnummer 10, kolom 1:<?xml version="1.0" encoding="UTF-8" ?>
            ^

            Your help very much appreciated!
              Happy to have left Back Pain | Sciatica behind.
              • 22164
              • 50 Posts
              I also tried putting the php code in front of the ditto snippet code, that did not do it either.
                Happy to have left Back Pain | Sciatica behind.
                • 7231
                • 4,205 Posts
                This &#160; &#160; is dirt you do not want this (I think those are tabs)
                <?php
                $defaultParent = 10; // default parent id if nothing else is defined
                if($_GET["blogCatID"]) {
                    $defaultParent = (int) $_GET["blogCatID"];
                }
                
                $modx->setPlaceholder("dittoRSSParent", $defaultParent);
                
                ?>

                Should work now. However you do not need to set a placeholder, simply return the value and use the snippet itself as the value for parents:
                [[Ditto? &parents=`[!getCat!]` &tpl=`...` etc.]]


                The snippet would look like this
                <?php
                $defaultParent = 10; // default parent id if nothing else is defined
                if($_GET["blogCatID"]) {
                    $defaultParent = (int) $_GET["blogCatID"];
                }
                
                return $defaultParent;
                
                ?>


                A third option (and the one that I use the most) is to use a wrapper snippet and call Ditto from within the wrapper. Here is a somewhat complex example that I used recently (posted just to illustrate the possibilities):
                <?php
                // read the variable from the URL
                $default = $modx->runSnippet("Ditto", array("docid" => "0"));
                $parents = isset($_GET["cat"]) ? $_GET["cat"] : $default;
                $doc = $modx -> documentIdentifier;
                $display = "20";
                $tpl = "RSSTpl";
                
                // run ditto snippet
                if(!isset($_GET["cat"])){
                $output = $modx->runSnippet("Ditto", array(
                	"debug" => "0",
                	"parents" => $parents,
                	"format" => "rss",
                	"display" => $display,
                	"tpl" => $tpl,
                	"depth" => "0",
                	"filter" => "id,".$doc.",2"   ));
                } else {
                $output = $modx->runSnippet("Ditto", array(
                	"debug" => "0",
                	"parents" => "0",
                	"format" => "rss",
                	"display" => $display,
                	"tpl" => $tpl,
                	"depth" => "0",
                	"tags" => $parents,
                	"tagData" => "parent",
                	"tagMode" => "onlyTags",
                	"tagDelimiter" => ","  ));
                	}
                	
                return $output;
                ?>
                  [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]
                  • 22164
                  • 50 Posts
                  Thanks for your work!

                  I am still not getting it to work.

                  I prepended the code before the ditto snippet code and the rss feed page does show, but there is nothing happening when I add something to the end like ?id=94 or whatever number it may be.

                  I am a bit lost as to what to do, it reads so simple what you say:
                  simply return the value and use the snippet itself as the value for parents:
                  but I have no clue what to do with that.

                  How about I give you access to one of my modx sites and you get it set up, I am willing to pay for the help.

                  thanks

                  OliverF
                    Happy to have left Back Pain | Sciatica behind.
                    • 24144
                    • 1 Posts
                    i also try rss feed and that php code.. all stuff work laugh
                      Qertis Werti Xasder, Jr.
                      • 7231
                      • 4,205 Posts
                      Quote from: OlivierF at Dec 11, 2008, 02:06 PM

                      I prepended the code before the ditto snippet code and the rss feed page does show, but there is nothing happening when I add something to the end like ?id=94 or whatever number it may be.
                      You cant use ?id=94 because id is a parameter reserved for modx. The script is setup to use blogCatID=94 (or if you use my last script example it is set to use cat=94).

                      Hope this helps.
                        [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]