We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11076
    • 159 Posts
    Hi there.. smiley

    I’m Using getFeed 1.0.0-rc1 over 2.0.4-pl2 to get feeds from EPN Products.

    [[!getFeed? 
       &url=`http://www.epn-online.com/rss/index/type_art/Top+product`
       &tpl=`epnFeedTpl`
       &limit=`3`
    ]]
    


    .epnFeedTpl Chunk (Formmating Items grabed from "EPN Online - Top products" feed for getFeed.)
    <div>
    	<p><img src="[[!EPN_IMG_PULL? &URL=[[+link]]]]" />
    	<br /><a href="[[+link]]">[[+title]]</a> 
    	<br />[[+description:ellipsis=`250`]]
    	<br />[[+pubdate:fuzzydate]]</p>  
    </div>  
    

    [[!EPN_IMG_PULL? &URL=[[+link]]]]

    As you can see The Structure of the feed contains Title, Link, Description & Date, but doesn’t have the appropriate Image from the original Item.
    Therefore I’ve Scribbled a Snippet that used-with/gets Item’s URL from the getFeed PlaceHolder inside the tpl chunk
    and grabs the content, striping and pulling the picture of item’s URL ,when it possible (if the page has one).

    Custom Snippet:
    //PULL EPN's PRODUCT IMAGE ACCORDING TO GIVEN URL.
    //OUTPUT: DIRECT-IMAGE-URL
    
    <?php
    // Default Image InCase Object isn't found.
    	$default = 'http://www.epn-online.com/images/logo.png';
    
    	// Fetch content from given address.
    	$c = curl_init();
    	curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($c, CURLOPT_URL, $URL);
    	$contents = curl_exec($c);
    	curl_close($c);
    
            // Strip to get the name of the image.	
    	if ($contents) {
                    $root = 'http://www.epn-online.com/lib/image.php?uri=/content/users/';
    
    		$start = '/lib/image.php?uri=/content/users/';
    		$end = '" class="article_details_data_image';
    		$ini = strpos($contents,$start);
    		if ($ini === false)
    			return $default;
    			
    			$ini += strlen($start);
    			$len = strpos($contents,$end,$ini) - $ini;
    			return ($root.substr($contents,$ini,$len));
    	}
    	else return $default;
    ?>
    


    (example of a single item page from the feed that i trying to pull from)


    It’s all works fine right to the purpose but it’s very un-efficient and slow.
    Which is not surprising because of all the snippet calls ,HTTP Requests, pulling-striping-manipulating process (aside with the work MODx itself does processing),
    and thank god i didn’t need to use Regex in this specific case.


    And Now To The Big Questions..

    As far as i know getFeed is based on magpieRSS which has default cache settings that isn’t much of configurable from getFeed.
    I don’t really know so well how the MODx’s cache system works to figure out how to do it in the best-efficient way.
    so, how can it be done in the best way?



    • Maybe it’s better to use spiefeed which is based on SimplePie and has some cache options?

    • Or maybe somehow use getCache to cache & speed things up?



    umm..
    more advanced idea i got in mind:

    • Is it possible to produce Resource from the feed and archive it?


    Many Thanks for reading this topic through getting this far ,haha.. tongue
      Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
      • 22303 MODX Staff
      • 10,725 Posts
      The internal API that getFeed uses definitely needs improvement. Also, SimplePie is scheduled to replace the magpie currently being used by the core in 2.1.

      That said, for your purposes, it might be better to create your own Snippet using SimplePie (or try spiefeed), though with what you are trying to do, it doesn’t sound like there is going to be any truly efficient way to accomplish this overall without the feed including the image.
        • 11076
        • 159 Posts
        Thanks for the reply jason.

        So I assume that it’s better to use spiefeed/SimplePie and it’s nested cache options
        rather than (getFeed + getCache) combination ,right? i’m not sure umm..
        (and do getCache’s Cache overcomes on getFeed’s default caching??)

        I know what i’m trying to achieve seems inapplicable in terms of efficiency,
        but i know there’s a way to workaround it. that’s the great thing about cache, isn’t it?
        at least using getCache to the EPN_IMG_PULL snippet.

        (umm.. how cron job and modx get along together?? sounds difficult, it’s better of escape this if possible -
        but how to spare the initial first havy load every pre-caching) , i’m troubled


        There’s must be a way to sample the feed occasionally, maybe in some spesific time interval and cache the results to load as some kind of re-produced static resource (if so, i can achive an archive of all the feeds gathered as resources). i don’t know, i’m just guessing my options here smiley

        some ideas, workflow, guidelines or general direction or actually anything will help alot.

        sincerely yours,
        designer, and a php newbie grin
          Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
          • 11055 ☆ A M B ☆
          • 3,112 Posts
          Try the spiefeed for its caching options.
            Rico
            Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
            MODx is great, but knowing how to use it well makes it perfect!

            www.virtudraft.com

            Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

            Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

            Maintainter/contributor of Babel

            Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
            • 11076
            • 159 Posts
            Quote from: goldsky at Nov 28, 2010, 05:23 AM

            Try the spiefeed for its caching options.
            i will, but still few issues remain,the initial load time.. (and using getFeed to cache my customized snippet pulling the image)

            Quote from: gOmp at Nov 21, 2010, 06:15 PM

            1] How cron job and modx get along together??
            how to spare the initial first havy load every pre-caching , i’m troubled
            There’s must be a way to sample the feed occasionally, maybe in some spesific time interval and..

            2] ..cache the results to load as some kind of re-produced (static?) resource (if so, i can achive an archive of all the feeds gathered as resources).
            i don’t know, i’m just guessing my options here smiley

            some ideas, workflow, guidelines or general direction or actually anything will help alot.

            -

            for now i’m using it in this manner:
            [[!getCache? &namespace=`getFeed` &element=`getFeed` &cacheExpires=`120` &url=`http://www.epn-online.com/rss/index/type_art/Top+product` &tpl=`epnFeedTpl` &limit=`3`]]

            	<img src="[[!getCache? &element=`EPN_imgPull` &cacheExpires=`120` &URL=[[+link]]]]" /> <br \>
            	<a href="[[+link]]">[[+title]]</a> <br \>
            	[[+description:WholeWords=`250`]]  <br \>
            	[[+pubdate:strtotime:date=`%A %d, %B %Y`]]

            and the same custom snippet i mentioned before. ..monotoring everything with:
            Total Time: [^t^] | Source: [^s^]

            in the end of the page.
              Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
              • 11076
              • 159 Posts
              *bump* laugh
                Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...