We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26334
    • 77 Posts
    OK it is at the xml_parse level within php itself.

    From the doco pages for that at php.net is the line:
    "It fails to capture any datums which are equal to numerical zero."

    Considering work arounds now but can’t think of any.
      • 26334
      • 77 Posts
      OK, day and a half tracking down the problem, 2 minutes fixing it!

      Using PhX on any field that may goto zero I simply apply this PhX snippet:

      <?php
      if ($output == '') {
          $output = 0;
        }
        return $output;
      ?>


      Whilst not perfect and can slip up if there is genuinely no data in that field rather than zero for me this will work. Hope it may help some others.

        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Actually, that would work nicely; you could have it say "No Data" or anything else you wanted.

        I wonder if it would be possible (or helpful) to convert the feed input to string before processing it? Would a string value of ’0’ be handled as a numerical 0?
          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
          • 26334
          • 77 Posts
          That is a good idea but I don’t have control of all the feeds so that would mean grabbing the feed from an external site, saving it locally, looking for zeros in the xml and replacing with capital o’s.

          Would probably work on a display basis as you said but it is a much longer work around the way my brain looks at it anyway.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Well, I’m not sure exactly how that works, I guess the xml_parse function gets the feed itself? otherwise, would it be possible to run the xml file through a to_string function before feeding it to xml_parse?
              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
              • 22770
              • 285 Posts
              Okay, I’ve got FeedX up and running, and it’s working fantastically so far, but I’m trying to work out how to do a few more things with it.

              Here is an example of the feed I’m using:

              http://ulpd.leeds.ac.uk/ulpd/template/file1.xml?PersonID=409

              It is basically a feed of academic publications by a particular author. The key element in here is the PublicationType tag. It can hold three different values: Journal, Chapter or Book.

              Right now, I’m using the following call to select all of the entries tagged Journal:
              [!FeedX? &url=`http://ulpd.leeds.ac.uk/ulpd/template/file1.xml|xq|PersonID|xe|409` &filterElements=`PUBLICATIONVIEW(PUBLICATIONTYPE NE /Journal/)` &preset=`publicationsJournal` &cacheType=`1`!]


              My templates within the publicationsJournal preset are:
              outer.tpl
              {{ROOT->inner}}


              inner.tpl
              <h3>Journal Articles</h3>
              <ul>
              {{PUBLICATIONVIEW->publication}}
              </ul>


              publication.tpl
              <li>[+AUTHORS+] ([+YEARPUB+]) [+TITLE+]. <em>[+PUBIN+]</em>[+VOLUME:isnt:then=`, <strong>[+VOLUME+]</strong>`+][+PAGES:isnt:then=`, [+PAGES+]`+].</li>


              My questions are these:

              Firstly, can I do the filtering within the inner.tpl, for example, rather than in the actual snippet call. It would be useful to be able to have something like:

              inner.tpl
              <h3>Journal Articles</h3>
              <ul>
              {{PUBLICATIONVIEW(filter to give me items with tag Journal)->publication}}
              </ul>
              <h3>Books</h3>
              <ul>
              {{PUBLICATIONVIEW(filter to give me items with tag Book)->publication}}
              </ul>
              <h3>Chapters</h3>
              <ul>
              {{PUBLICATIONVIEW(filter to give me items with tag Chapter)->publication}}
              </ul>

              rather than having to call the snippet and process the feed three times.

              Secondly, is there any way I could rewrite this so that the html being inserted around the {{PUBLICATIONVIEW->publication}} is only displayed if there are any results that match the appropriate filter?
                • 22770
                • 285 Posts
                And another question: Caching.

                How exactly does the caching work in FeedX?

                First up, there is the &cacheType parameter, which can be set to 0 or 1, with 1 caching the content of the snippet call and 0 only caching the feed.

                Then there is the snippet call itself. Right now, I’m calling it using [!FeedX etc....!] which should produce an uncached snippet call.

                How do these two things interact? Which takes precedence?

                The feed I am importing will be only updated about once a month, so I want it to be cached essentially until the entire site cache is cleared. My guess is that I should set &cacheType to 0 and call the snippet cached, but I might be talking nonsense here. laugh

                Anyone out there know more than me...?
                  • 12658
                  • 9 Posts
                  I am interested in knowing if I can limit the number of items returned by FeedX. Right now it’s outputting every rss entry and I haven’t been able to figure out how to limit this.

                  Any ideas?
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    The "documentation" is in the comments in the snippet itself.
                    $params[’maxElements’] = isset($maxElements) ? $maxElements : ’’;
                    // Maximum number of times to display a repeating element
                    // This setting will be overridden by any limit values in the template
                    // Use the colon replacement value for element names which include colons
                    // Syntax: ELEMENT_NAME(x) where x is the maximum number of times to display
                    // Multiple elements can be defined and must be separated by a colon
                    // Example: `CHANNEL(5):ITEM(10)`
                    http://modxcms.com/forums/index.php/topic,12657.msg170082.html#msg170082
                      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
                      • 26140
                      • 11 Posts
                      What is the lastest version of FeedX and where do I get it?