Create an RSS feed for several selected categories

0

If I do this link

I can create an RSS feed for a particular category. But what if I want to create an RSS feed for several selected categories? it's possible? The OSClass version is 3.3.2

    
asked by Pablo 26.12.2016 в 14:28
source

1 answer

0

I solved it like that, in case someone serves him

<?php


define('ABS_PATH', str_replace('\', '/', dirname($_SERVER['SCRIPT_FILENAME']) . '/'));
if(PHP_SAPI==='cli') {
    define('CLI', true);
}

require_once ABS_PATH . 'oc-load.php';

$mSearch = Search::newInstance();

$array_categorias = array("16","22","23","24","31","33","43","102","119","121","122","123","124");

$aItems  = $mSearch->doCustomSearch($array_categorias);

View::newInstance()->_exportVariableToView('items', $aItems);

 // FEED REQUESTED!
header('Content-type: text/xml; charset=utf-8');

$feed = new RSSFeed;
$feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title());
$feed->setLink(osc_base_url());
$feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title());

$contador_items = osc_count_items();

if(osc_count_items()>0) {
    while(osc_has_items()) {
        if(osc_count_item_resources() > 0){
            osc_has_item_resources();
            $feed->addItem(array(
                'title' => osc_item_title(),
                'link' => htmlentities( osc_item_url(),  ENT_COMPAT, "UTF-8" ),
                'description' => osc_item_description(),
                'dt_pub_date' => osc_item_pub_date(),
                'image'     => array(  'url'    => htmlentities(osc_resource_thumbnail_url(),  ENT_COMPAT, "UTF-8"),
                                       'title'  => osc_item_title(),
                                       'link'   => htmlentities( osc_item_url() ,  ENT_COMPAT, "UTF-8") )
            ));
        } else {
            $feed->addItem(array(
                'title' => osc_item_title(),
                'link' => htmlentities( osc_item_url() , ENT_COMPAT, "UTF-8"),
                'description' => osc_item_description(),
                'dt_pub_date' => osc_item_pub_date()
            ));
        }
    }
}

$feed->dumpXML();
?>
    
answered by 09.01.2017 / 18:25
source