我想询问如何将价格包含在与Osclass一起运行的网站的RSS Feed标题中。
喜欢这个[价格/标题(联系电话)]
public function dumpXML() {
echo '<?xml version="1.0" encoding="UTF-8"?>', PHP_EOL;
echo '<rss version="2.0">', PHP_EOL;
echo '<channel>', PHP_EOL;
echo '<title>', $this->title, '</title>', PHP_EOL;
echo '<link>', $this->link, '</link>', PHP_EOL;
echo '<description>', $this->description, '</description>', PHP_EOL;
foreach ($this->items as $item) {
echo '<item>', PHP_EOL;
echo '<title><![CDATA[', $item['title'], ']]></title>', PHP_EOL;
echo '<link>', $item['link'], '</link>', PHP_EOL;
echo '<guid>', $item['link'], '</guid>', PHP_EOL;
echo '<description><![CDATA[';
echo $item['description'], ']]>';
echo '</description>', PHP_EOL;
echo '<country>', $item['country'], '</country>', PHP_EOL;
echo '<region>', $item['region'], '</region>', PHP_EOL;
echo '<city>', $item['city'], '</city>', PHP_EOL;
echo '<cityArea>', $item['city_area'], '</cityArea>', PHP_EOL;
echo '<category>', $item['category'], '</category>', PHP_EOL;
echo '</item>', PHP_EOL;
}
echo '</channel>', PHP_EOL;
echo '</rss>', PHP_EOL;
}
}
谢谢你
答案 0 :(得分:1)
通常情况下,我会告诉你不要修改核心。你有一个专门为此目的设计的钩子:'feed'但似乎你无法访问数据。所以你必须修改核心。
在oc-includes / controllers / search.php中的'price' => osc_item_formated_price()
次调用中添加一行addItem()
:
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(),
'country' => osc_item_country(),
'region' => osc_item_region(),
'city' => osc_item_city(),
'city_area' => osc_item_city_area(),
'category' => osc_item_category(),
'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(),
'country' => osc_item_country(),
'region' => osc_item_region(),
'city' => osc_item_city(),
'city_area' => osc_item_city_area(),
'category' => osc_item_category(),
'dt_pub_date' => osc_item_pub_date()
));
}
}
然后,您可以通过在某处添加echo $item['price']
来修改RSSfeed :: dumpXML方法。
PS: 我将尝试在Osclass Github中进行提交以使feed钩可用。