Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: Enhanced RSS Feeds

  1. #21
    Junior Member
    Join Date
    Oct 2010
    Location
    London, England.
    Posts
    16
    Thanks
    5
    Thanked 5 Times in 3 Posts

    Default

    Quote Originally Posted by xcitezone View Post
    I have changed the code in PostRssFunctions.php but still Images are not visible
    Xcitezone, you'll need to provide more information about your setup. But first, here's 2 things you could try:

    1. Make sure you "clear all caches" in the admin
    2. If you're using Feedburner for your feeds, you'll need to go to their "Troubleshootize" page and click the Resync Feed button at the bottom.

  2. #22
    Junior Member
    Join Date
    Nov 2010
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    first check the site http://hotlinks.xcitezone.com
    I cleared all the caches in Admin and I am not using feedburners for feeds

  3. #23
    Junior Member
    Join Date
    Oct 2010
    Location
    London, England.
    Posts
    16
    Thanks
    5
    Thanked 5 Times in 3 Posts

    Default

    Quote Originally Posted by xcitezone View Post
    first check the site http://hotlinks.xcitezone.com
    I cleared all the caches in Admin and I am not using feedburners for feeds
    Seems fine from what I can tell. Maybe you should post your PostRssFunctions.php for us to have a look at.

    Also, consider redirecting your feed through Feedburner. It's a good service, provides subscriber stats, plus I've only tested my RSS image code whilst using them. Though, in theory, it should work without.

  4. #24
    Junior Member
    Join Date
    Nov 2010
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <?php
    /**
     * Post RSS functions
     *
     * PHP version 5
     *
     * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 
     * modify it under the terms of the GNU General Public License as 
     * published by the Free Software Foundation, either version 3 of 
     * the License, or (at your option) any later version. 
     *
     * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
     * FITNESS FOR A PARTICULAR PURPOSE. 
     *
     * You should have received a copy of the GNU General Public License along 
     * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
     * 
     * @category  Content Management System
     * @package   HotaruCMS
     * @author    Nick Ramsay <admin@hotarucms.org>
     * @copyright Copyright (c) 2009, Hotaru CMS
     * @license   http://www.gnu.org/copyleft/gpl.html GNU General Public License
     * @link      http://www.hotarucms.org/
     */
    
    class PostRssFunctions
    {
        protected $feed_array   = array();  // contains a prepared SQL query
        protected $feed_results = NULL;     // object containing the results of the above query
        
        
        /**
         * Access modifier to set protected properties
         */
        public function __set($var, $val)
        {
            $this->$var = $val;
        }
        
        
        /**
         * Access modifier to get protected properties
         * The & is necessary (http://bugs.php.net/bug.php?id=39449)
         */
        public function &__get($var)
        {
            return $this->$var;
        }
        
        
        /**
         * Publish content as an RSS feed
         * Uses the 3rd party RSS Writer class.
         *
         * This function checks the url for the kind of feed
         * and builds a prepared SQL query
         */    
        public function postRssFeedQuery($h)
        {
            // Feed details
            $h->vars['postRssFeed']['title'] = SITE_NAME;
            $h->vars['postRssFeed']['link'] = BASEURL;
            // description set further down...
    
            // Limit:
            if ($h->cage->get->keyExists('limit')) {
            	$h->vars['postRssLimit'] = $h->cage->get->getInt('limit');
            }
            
            $this->postRssStatus($h);
            
            // allow other plugins to create a feed
            $h->pluginHook('post_rss_feed');
    
            // set post rss filter defaults if not already set
            $this->checkPostRssDefaults($h);
            
            // default to posts of type "news" if not otherwise set
            if (!isset($h->vars['postRssFilter']['post_type = %s'])) { 
            	$h->vars['postRssFilter']['post_type = %s'] = 'news';
            }
            
            // get the prepared SQL query
            $this->feed_array = $h->db->select(
            	$h,
            	array($h->vars['postRssSelect']),
            	'posts',
                $h->vars['postRssFilter'],
                $h->vars['postRssOrderBy'],
                $h->vars['postRssLimit']
            );
            
            return $this->feed_array;
        }
        
        
        /**
         * check post status for the RSS feed
         */
        public function postRssStatus($h)
        {
            $h->vars['postRssStatus'] = $h->cage->get->testAlpha('status');
            
            if (!$h->vars['postRssStatus']) { return false; }
            
            $h->vars['postRssFilter']['post_status = %s'] = $h->vars['postRssStatus'];
            
            switch ($h->vars['postRssStatus']) {
                case 'new':
                    $h->vars['postRssFeed']['description'] = $h->lang["post_rss_latest_from"] . " " . SITE_NAME; 
                    break;
                case 'top':
                    $h->vars['postRssFeed']['description'] = $h->lang["post_rss_top_stories_from"] . " " . SITE_NAME;
                    break;
                case 'upcoming':
                    $h->vars['postRssFeed']['description'] = $h->lang["post_rss_upcoming_stories_from"] . " " . SITE_NAME;
                    // Filters page to "new" stories by most votes, but only stories from the last X days!
                    
                    // figure out what vote plugin is being used and get the upcoing duration from that plugin's settings
                    $sql = "SELECT plugin_folder FROM " . TABLE_PLUGINS . " WHERE plugin_type = %s AND plugin_enabled = %d";
                    $vote_plugin = $h->db->get_var($h->db->prepare($sql, 'vote', 1));
                    $vote_settings = unserialize($h->getSetting($vote_plugin . '_settings', $vote_plugin));
                    $upcoming_duration = "-" . $vote_settings['upcoming_duration'] . " days"; // default: -5 days
                    
                    $h->vars['postRssFilter']['post_status = %s'] = 'new'; 
                    $start = date('YmdHis', strtotime("now"));
                    $end = date('YmdHis', strtotime($upcoming_duration)); // should be negative
                    $h->vars['postRssFilter']['(post_date >= %s AND post_date <= %s)'] = array($end, $start); 
                    $h->vars['postRssOrderBy'] = "post_votes_up DESC, post_date DESC";
                default:
                	
            }
        }
    
    
        /**
         * Set Post RSS filter defaults if not already set
         */
        public function checkPostRssDefaults($h)
        {
            // if no select set...
            if (!isset($h->vars['postRssSelect'])) { 
                $h->vars['postRssSelect'] = '*'; 
            }
            
            // if no order by set...
            if (!isset($h->vars['postRssOrderBy'])) { 
                $h->vars['postRssOrderBy'] = 'post_date DESC'; 
            }
            
            // if no filter set...
            if (!isset($h->vars['postRssFilter'])) {
                $h->vars['postRssFilter']['(post_status = %s || post_status = %s)'] = array('top', 'new'); // default to all posts
            }
            
            // if no limit set...
            if (!isset($h->vars['postRssLimit'])) { 
                $h->vars['postRssLimit'] = 10; 
            }
            
            // if no feed title set...
            if (!isset($h->vars['postRssFeed']['title'])) { 
                $h->vars['postRssFeed']['title'] = SITE_NAME; 
            }
            
            // if no feed link set...
            if (!isset($h->vars['postRssFeed']['link'])) { 
                $h->vars['postRssFeed']['link'] = BASEURL; 
            }
            
            // if no feed description set...
            if (!isset($h->vars['postRssFeed']['description'])) { 
                $h->vars['postRssFeed']['description'] = $h->lang["post_rss_from"] . " " . SITE_NAME;
            }
        }
        
        
        /**
         * Assign values to $feed object and serve the feed
         *
         * @param object $results - post rows
         */
        public function doPostRssFeed($h, $results = NULL)
        {
            if (!$results) { return false; }
            $title    = $h->vars['postRssFeed']['title'];
            $link     = $h->vars['postRssFeed']['link'];
            $description = $h->vars['postRssFeed']['description'];
    
            $items = array();
            
            foreach ($results as $result) 
            {
                $h->post->url = $result->post_url; // used in Hotaru's url function
                $h->post->category = $result->post_category; // used in Hotaru's url function
             
                $item['title'] = $result->post_title;
                $item['link']  = $h->url(array('page'=>$result->post_id));
                $item['date'] = $result->post_date; 
    			if($result->post_img!==''){
    			         $item['description']  = "<img src=".SITEURL."content/images/post_images/".$result->post_img." >";
    			}
               // $item['description']  = $result->post_img;
    
    
                $h->vars['post_rss_item'] = $item;
                $h->pluginHook('post_rss_feed_items', '', array('result'=>$result));
                
                array_push($items, $h->vars['post_rss_item']);
            }
            
            // do it!
            $h->rss($title, $link, $description, $items);
        }
    }
    ?>

  5. #25
    Junior Member
    Join Date
    Oct 2010
    Location
    London, England.
    Posts
    16
    Thanks
    5
    Thanked 5 Times in 3 Posts

    Default

    xcitezone,

    Try using my fix AS IS first and see if it works. You can then modify it to suit your needs from there.

    It looks as though you're trying to ONLY display images with no description - which should be possible - but you're using double quotes in your code which would probably pull errors.

  6. #26
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    35
    Thanked 38 Times in 26 Posts

    Default

    Hey Mark,

    Is there any way to also allow for a thumbnail of the videos to be displayed in the rss feed?

    Thanks


    Quote Originally Posted by mystermarque View Post
    Nick, you beat me to it! I was just about to post a solution I hacked together last night. I'll put it here anyway as I've tested it and it works. I just tried yours on Hotaru 1.4.1 and it's pulling errors for some reason.

    Replace (near bottom of PostRssFunctions.php):
    PHP Code:
    $item['description'] = $result->post_content
    With the following:
    PHP Code:
    $item['description'] = '<a href="' $h->url(array('page'=>$result->post_id)) . '"><img src="' BASEURL 'content/images/post_images/' $result->post_img '" title="' $result->post_title .  '" alt="' $result->post_title '"></a><p>' $result->post_content '</p>'
    Cheers,
    Mark.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •