homepage Welcome to WebmasterWorld Guest from 54.205.236.46
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
Forum Library, Charter, Moderators: bill & werty

RSS, ATOM, and Related Technologies Forum

    
Limit RSS feed entries in PHP/XML/MYSQL environment
rss limit entries
imofloripa




msg:4266085
 12:33 pm on Feb 12, 2011 (gmt 0)

Hello,

I have a real estate website, a rss feed and I use feedburner for email subscriptions etc.

Since last week, feedburner is not working anymore cause it says that my feed is larger than 512 KB.

Well, i would like to change the code of the feed in order to display only the last 200 items (now we have 300), but i tried many ways and didnt have any luck :(

Another solution would be setting a minimum date for publishing the items, for example to set the feed to publish items only if their publication date was after a particular month or day.

here is my code, can you help me to limit number of items, please?

Thanks in advance




<?php
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

class PropertiesViewProperties extends JView
{



function display($tpl = null)



{








global $mainframe;





$db







=& JFactory::getDBO();





$document



=& JFactory::getDocument();





$params =& $mainframe->getParams();





$document->link = JRoute::_('index.php?option=com_properties&view=properties');



$document->setMetaData('description',JURI::base());





// Get some data from the model





JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));


$query = ' SELECT p.*,c.name as name_category,t.name as name_type,cy.name as name_country,s.name as name_state,l.name as name_locality,pf.name as name_profile,pf.logo_image as logo_image_profile, '
. ' CASE WHEN CHAR_LENGTH(p.alias) THEN CONCAT_WS(":", p.id, p.alias) ELSE p.id END as Pslug,'
. ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as Cslug,'
. ' CASE WHEN CHAR_LENGTH(cy.alias) THEN CONCAT_WS(":", cy.id, cy.alias) ELSE cy.id END as CYslug,'
. ' CASE WHEN CHAR_LENGTH(s.alias) THEN CONCAT_WS(":", s.id, s.alias) ELSE s.id END as Sslug,'
. ' CASE WHEN CHAR_LENGTH(l.alias) THEN CONCAT_WS(":", l.id, l.alias) ELSE l.id END as Lslug, '
. ' CASE WHEN CHAR_LENGTH(t.alias) THEN CONCAT_WS(":", t.id, t.alias) ELSE t.id END as Tslug '
. ' FROM #__properties_products AS p '
. ' LEFT JOIN #__properties_country AS cy ON cy.id = p.cyid '
. ' LEFT JOIN #__properties_state AS s ON s.id = p.sid '
. ' LEFT JOIN #__properties_locality AS l ON l.id = p.lid '
. ' LEFT JOIN #__properties_profiles AS pf ON pf.mid = p.agent_id '
. ' LEFT JOIN #__properties_category AS c ON c.id = p.cid '
. ' LEFT JOIN #__properties_type AS t ON t.id = p.type '
. ' WHERE p.published = 1 '
.' ORDER BY p.id DESC'
;










$db->setQuery( $query );


















$prod = $db->loadObjectList();

























foreach ( $prod as $row )





{












// strip html from feed item title







$title = $this->escape( $row->name );







$title = html_entity_decode( $title );







// url link to article














$link = LinkHelper::getLink('properties','showproperty','',$row->CYslug,$row->Sslug,$row->Lslug,$row->Cslug,$row->Tslug,$row->Pslug);







// strip html from feed item description text







$image_name=$this->Images($row->id);










//print_r($image_name);







//require('a');







$image = '<img width="200" align="left" alt="'.$item->title.'" src="'.JURI::base().'images/properties/images/thumbs/'.$row->id.'/'.$image_name.'"/>';







$category = '&nbsp;'.JText::_('Category').': <b>'.$row->name_category.'. </b>';







$desc = '<br>'.'<br>'.'<div align="center" style="border: 1px solid red; margin: 10px; padding: 20px;">'.$row->text.'</div>';





















$description = $image.$category.$type.$ref.$desc;







$description = $this->escape( $description );







$description = html_entity_decode( $description );







$listdate = $row->listdate;







// load individual item creator class







$item = new JFeedItem();














$item->title





= $title;







$item->link





= $link;







$item->description



= $description;







$item->date







= $listdate;







$item->category



= $row->name_category;







$item->type



= $row->name_type;







// loads item info into rss array







$document->addItem( $item );





}







}












function Images($id)



{









$db



=& JFactory::getDBO();






$query = ' SELECT i.name '














. ' FROM #__properties_images as i '


















. ' WHERE i.published = 1 AND i.parent = '.$id














. ' order by i.ordering LIMIT 1';






$db->setQuery($query);





$Images = $db->loadResult();



return $Images;



}







}
?>


 

bill




msg:4322753
 7:44 am on Jun 7, 2011 (gmt 0)

Is this a Joomla feed? It's not XML, although it may feed some information into something that eventually becomes a proper feed.

imofloripa




msg:4322846
 11:37 am on Jun 7, 2011 (gmt 0)

yes it is a joomla feed....

imofloripa




msg:4322847
 11:38 am on Jun 7, 2011 (gmt 0)

can anyone tell me where to start learning XML? maybe some good resources online or some book... I need to learn to make simple xml integrations..

bill




msg:4323298
 5:26 am on Jun 8, 2011 (gmt 0)

can anyone tell me where to start learning XML?

We do have an XML development forum [webmasterworld.com] where some of our pros could probably point you in the right direction.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved