[英]How To Price included in the Osclass RSS Feed Title?
I would like to ask on how to include the price in the RSS Feed Title in website running with Osclass. 我想问一下如何在使用Osclass运行的网站的RSS Feed标题中包含价格。
Like This [Price / Title (Contact Number)] 赞[价格/标题(联系电话)]
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;
}
}
Thanks You 谢谢
Normally, I would tell you not to modify the core. 通常,我会告诉您不要修改内核。 You have a hook available designed for this purpose : 'feed' but it seems you can't access the data.
您有一个专门用于此目的的钩子:'feed',但看来您无法访问数据。 So you'll have to modify the core.
因此,您必须修改核心。
Add a line 'price' => osc_item_formated_price()
to both addItem()
calls in oc-includes/controllers/search.php : 在oc-includes / controllers / search.php中的两个
addItem()
调用中添加一行'price' => osc_item_formated_price()
:
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()
));
}
}
Then you'll be able to modify the RSSfeed::dumpXML method by adding a echo $item['price']
somewhere. 然后,您可以通过在某处添加
echo $item['price']
来修改RSSfeed :: dumpXML方法。
PS: I'll try to make a commit in the Osclass Github to make the feed hook usable. PS:我将尝试在Osclass Github中进行提交,以使提要挂钩可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.