We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10395
    • 96 Posts
    So basically, create a snippet to call a snippet tongue.

    Thanks, and I will look forward to the "revised" version lol.

      • 19315
      • 84 Posts
      Hi,

      I have just written a snippet ("xslt") that I now see can give a very similar function to this snippet. It processes a remote XML file using a local XSL file. I thought this was quite good, and people could find it useful and use it for various things. However, I now read the comments in the source for this snippet
      One feed processor from a large Content Management System written in PHP nearly got me kicked off my server. It ran wild with overly complex coding and included opening hundreds of objects in a loop and used the XML-DOM (ugh!).
      I used the PHP DOM XML functions to do the processing. It this a bad idea? I could possibly see it is a necessary if you do have a non-RSS feed, or a complex XSL file to transform it, but perhaps for a simple RSS feed transform it is overkill. Should I perhaps put in the instructions for the xslt snippet that they should in fact use this one for simple display of RSS feeds?

      Michal.
        • 30394
        • 7 Posts
        Hi,

        Thanks for all the good work on this...

        I was sifting through the class and found a showdesc switch. How do I activate this in the call?

        Thanks,

        Tony

        EDIT: Duh. I found it... should have looked before posting....

        it’s not in the sample code, but add "?descr =1" to the snippet call. same applies to all the params as mentioned in the snippet code

        if ( $url == "" ) return false;
        if ( $limit == "" ) $limit = "0";
        if ( $image == "" ) { $bimage = false; } else { $bimage = true; }
        if ( $descr == "" ) { $bdescr = false; } else { $bdescr = true; }
        
          • 30897
          • 311 Posts
          Modification of NewsParserX for problem encoding caracters : http://modxcms.com/forums/index.php/topic,2491.msg80918.html#msg80918
            TylerD - In MODx we trust
            [Derni
            • 9022
            • 4 Posts
            Hi.
            Im trying to get NewsParserX to work on a MODx 0.9.2.2 installation.
            But all im getting is "The connection was reset
            The connection to the server was reset while the page was loading."

            What am i doing wrong?
            The RSS URL im trying to load is:
            http://www.mil.se/rss/forsvarsmakten/
            According to http://www.mil.se/article.php?id=15309 (unfortunatley in swedish but feedvalidator have confirmed that the RSS feed is valid and does not contain malformed syntax etc. ( http://feedvalidator.org/check.cgi?url=http%3A//www.mil.se/rss/forsvarsmakten )

            I have uploaded the newsparserx.inc.php to assets/snippets/newsparserx/
            Is there somewhere i have to allow running of php in that dir?

            I have tried without trailing slash and also with index.html at the end but i am still getting the same.

            Turning on debug does not give any more clue?

            Any ideás?
            Anyone that can try this with their working NewsParserX? To verify if it is a site settings problem or NewsParserX config problem?
              • 22303 MODX Staff
              • 10,725 Posts
              I just tested the feed URL on a local test installation with NewsParserX and it immediately displayed the feed, with no problems. Did you copy and paste the snippet into a new snippet for NewsParserX as well? Can you paste the exact template tag or API call you are using to call NewsParserX?
                • 30897
                • 311 Posts
                Hi,

                When I call this feeds : http://www.whynet.org/forums/index.php?act=rssout&id=1, NewsParserX does not shox the feed and there is no error...

                This feed is correct and it’s display on rss page like netvibes... can you help me ?
                  TylerD - In MODx we trust
                  [Derni
                  • 9022
                  • 4 Posts
                  Quote from: OpenGeek at Feb 17, 2007, 02:01 PM

                  I just tested the feed URL on a local test installation with NewsParserX and it immediately displayed the feed, with no problems. Did you copy and paste the snippet into a new snippet for NewsParserX as well? Can you paste the exact template tag or API call you are using to call NewsParserX?
                  The webpage is unpublished? might that affect something?

                  I removed the
                  <?php
                  and the
                  ?>
                  from the snippet? do i have to do the same with the newsparserx.inc.php file?

                  The call from the webpage:
                  [[NewsParserX? &url=`http://www.mil.se/rss/forsvarsmakten/index.html`]]


                  The snippet:
                  NewsParserX

                  # NewsParserX - for MODx 0.9.x
                  # Version 0.9 - 2006-04-02
                  # By: OpenGeek - [email protected]
                  # RSS parser shamelessly adapted from the RSS_feed class
                  # see http://www.phpclasses.org/browse/package/1299.html
                  #
                  # This parser allows for more sorts of feeds 
                  # and by using a simple URL translation allows for parsing of URLs
                  # which use variables within the URL
                  # The class can also limit the number of items shown and show the image
                  # For interoperatebility, the same CSS classes are used
                  # as in rad's NewsParser snippet ;-)
                  # 
                  # usage:
                  # [[NewsParserX? &url=`http://modxcms.com/forums/index.php|xq|sa|xe|recent;type|xe|rss2;action|xe|.xml|xa|limit|xe|20`]]
                  # or:
                  # $modx->runSnippet('NewsParserX', array('url'=> 'http://modxcms.com/forums/index.php?sa=recent;type=rss2;action=.xml&limit=20'));
                  #
                  # Changes:
                  # 1. 2006-04-02: Removed htmlentities() call to allow complex URLs to operate properly.
                  #
                  # original credits and comments kept:
                  /********************************************************************
                   Class: RSS_feed
                   Author: Dr. Timothy Sakach
                   Version 2.0
                   This script will parse a RSS/XML file that comes from a URL feed.
                   It will return an HTML unordered list.
                  
                   Getting a feed from another web site, should be quick and simple. Any
                   unneeded complications should be avoided. One feed processor from a
                   large Content Management System written in PHP nearly got me kicked 
                   off my server. It ran wild with overly complex coding and included 
                   opening hundreds of objects in a loop and used the XML-DOM (ugh!).
                  
                   This is far simpler, faster and more reliable.
                  
                   There are several versions of RSS/RDF. However, in practical use
                   most all feed implementations follow the same pattern: A publication link is
                   contained within <item> tags and consists of a <title>, <link>, and
                   a <description>. We tested feeds from many different sources using
                   all flavors and versions and this class was able to parse all of them.
                   
                   Granted there are many options with version 1.0 (RDF). However,  
                   the full RDF syntax and vocabulary are not needed in a feed. 
                   All of the implementations we found that included RDF tags 
                   really added very little to the feed and  were safely ignored. 
                  
                   Version 2.0 extends versions 0.9x by adding new tags. This presented
                   no problems and this class can be extended to process those tags. But 
                   our goal was to provide a simple solution that can easily add syndicated
                   publications to any web site.
                   
                    Changes: by Dr. Timothy Sakach
                    1. 8/31/03 Corrected bug because the description tag (and all other tags, for that
                       matter} can occur in any sequence within the container tags. 
                    2. 8/31/03 Corrected bug created by the way the XML parser returns parsed cdata.
                    3. 8/31/03 Added Set_Limit property to control the number of links to show.
                    4. 8/31/03 Added image control and Show_Image property.
                    5. 8/31/03 Channel, Image, and Items now use arrays as buffers.
                  ********************************************************************/
                  $output = '';
                  
                  // defaults and variable translation
                  $url = str_replace ( "|xq|", "?", $url );
                  $url = str_replace ( "|xe|", "=", $url );
                  $url = str_replace ( "|xa|", "&", $url );
                  //$url = htmlentities($url);
                  $url = html_entity_decode($url);
                  
                  if ( $url == "" ) return false;
                  if ( $limit == "" ) $limit = "0";
                  if ( $image == "" ) { $bimage = false; } else { $bimage = true; }
                  if ( $descr == "" ) { $bdescr = false; } else { $bdescr = true; }
                  // end of defaults and variable translation
                  
                  // load class if it doesn't already exist
                  //  to handle multiple instances per page
                  if (!class_exists("RSS_feed")) { include "assets/snippets/newsparserx/newsparserx.inc.php"; }
                  
                  $px = new RSS_feed();
                  
                  $px->Set_URL($url);
                  $px->Set_Limit($limit);		// 0 = Default = All
                  $px->Show_Image($bimage);		// Default = false
                  $px->Show_Description($bdescr);	// Default = false
                  
                  // $output .= "<br />" . $url . "<br />"; // for debugging
                  $output .= $px->Get_Results();
                  
                  return $output;
                    • 30389
                    • 1 Posts
                    Hi

                    I’ve been getting the same message as other people have been getting -
                    eg:
                    « MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: file(http://rss.someurl [function.file]: failed to open stream: No such file or directory
                    Error type/ Nr.: Warning - 2
                    File: /home/server/public_html/myurl/assets/snippets/newsparserx/newsparserx.inc.php
                    Line: 426
                    Line 426 source: $data = @file($this->URL) or die ("Could not open a feed called: " . $this->URL);

                    I spent a couple of days tearing my hair out trying to get it to work. I tried setting up a new Modx site using v0.9.2.2 (my main site is 0.9.5) without any luck.

                    Then I tried pasting in the entire sample snippet call insted of just the url and it worked OK! I’ve tracked down the problem to the fact that I was typing in the ’ character from the keyboard. If I paste in the ` character it works OK.
                    Maybe thats the cause of other peoples problems?

                    Unbelievable - after 15 years or more of using computers, I’ve just discovered the` key on the keyboard above the tab key!! Oh, the embarrassment! Now I can get other snippets working that I was struggling with.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      That’s probably the single biggest mistake and why we have the stickied topic in the (now) MODx 101 section (and it’s part of my signature, too!).
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me