We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10700
    • 104 Posts
    А вот NewsparserX заработал. Но появилась одна маленькая проблема. Ссылки открываются в том же окне. Хотелось бы прописать target="_blank" но не знаю где. Вот код сниппета:
    <?php
    # 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;
    ?>
      • 33303
      • 31 Posts
      Quote from: gerasim13 at Jul 27, 2008, 05:26 AM

      А вот NewsparserX заработал. Но появилась одна маленькая проблема. Ссылки открываются в том же окне. Хотелось бы прописать target="_blank" но не знаю где. Вот код сниппета:

      Лучше поздно чем никогда wink

      В newsparserx.inc.php поменять код примерно в 401 строке.


      С:
      $this->output .= "<a class='rssItemLink' href='" . $this->item["link"];


      На:
      $this->output .= "<a class='rssItemLink' target='_blank' href='" . $this->item["link"];