Osclass forums
Support forums => Tips, tricks, and tutorials => Topic started by: Alessandro on October 12, 2015, 02:44:02 pm
-
Hi all,
how can I add the ID and address info for each ad in the RSS code?
Is there a safe way to duplicate the feed stream (es: feed1, feed2, etc.)?
Here below the actual code applied in the Osclass feed.
<?php if ( ! defined('ABS_PATH')) exit('ABS_PATH is not loaded. Direct access is not allowed.');
/*
* Copyright 2014 Osclass
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This class takes items descriptions and generates a RSS feed from that information.
* @author Osclass
*/
class RSSFeed {
private $title;
private $link;
private $description;
private $items;
public function __construct() {
$this->items = array();
}
public function setTitle($title) {
$this->title = $title;
}
public function setLink($link) {
$this->link = $link;
}
public function setDescription($description) {
$this->description = $description;
}
public function addItem($item) {
$this->items[] = $item;
}
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[';
if(@$item['image']) {
echo '<a href="'.$item['image']['link'].'" title="'.$item['image']['title'].'" rel="nofollow">';
echo '<img style="float:left;border:0px;" src="'.$item['image']['url'].'" alt="'.$item['image']['title'].'"/> </a>';
}
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 '<pubDate>', date('r',strtotime($item['dt_pub_date'])) , '</pubDate>', PHP_EOL;
echo '</item>', PHP_EOL;
}
echo '</channel>', PHP_EOL;
echo '</rss>', PHP_EOL;
}
}
?>
-
in order to resolve my issue, how can I add a custom field in Osclass RSS Feed?
-
hello, I did not understand well what would you do, change the core osclass not recommended, I would install rss feed plugins (free) and then if necessary would the changes of my interest.
-
I need to add in the RSS Feed a custom field added in item post page.
I have already installed the extra feed plugin but it doesn't create a standard xml output.
Can you advise me of other free plugins?
-
hello, there are other free plugins, the only way is to create one specifically for your needs, I'm sorry, nothing else. :)
-
hello, there are other free plugins, the only way is to create one specifically for your needs, I'm sorry, nothing else. :)
So there aren't other plugins, I must create one... ;)
-
hello, try adding these two fields to the class rss feed:
echo '<address>', $item['s_address'], '</address>', PHP_EOL;
echo '<id>', $item['pk_i_id'], '</id>', PHP_EOL;
;)
-
hello, try adding these two fields to the class rss feed:
echo '<address>', $item['s_address'], '</address>', PHP_EOL;
echo '<id>', $item['pk_i_id'], '</id>', PHP_EOL;
;)
It doesn't work :(
ID and Address tag are still blank
<ad>
<id/>
<company/>
<title>
Hai passione verso il settore wellness e nutrizione?
</title>
<url>
http://www.buzzajob.it/piemonte/torino/hai-passione-verso-il-settore-wellness-e-nutrizione_i673
</url>
<address/>
<id/>
<content>
<![CDATA[
Selezioni per nuove figure richieste dal mercato Hai passione verso il settore wellness e nutrizione? Selezioniamo 4 candidati, per opportunità di lavoro come consulente. Possibilità in part time o in tempo pieno. Per avere maggiori informazioni e fissare un appuntamento per un colloquio, inviare il proprio CV.
]]>
</content>
<city>Torino</city>
<pubDate>Tue, 20 Oct 2015 21:47:37 +0200</pubDate>
</ad>
-
Hello,
I did some tests and saw that just as I said it will never work because some parameters are passed in the array variable item,
the 'only way to customize the feed is to create one specifically for your purpose.
-
Hello,
I did some tests and saw that just as I said it will never work because some parameters are passed in the array variable item,
the 'only way to customize the feed is to create one specifically for your purpose.
Ok, thanks for your kindly support.
So, as I said some posts ago, "there aren't other plugins, I must create one".
Bye
-
Eureka! I have fixed my RSS feed :)
Here below how to do:
add this in class RSSFeed
private $id;
and then declare the pubblic function:
public function setId($id) {
$this->id = $id;
}
and this in the public function dumpXML
echo '<id>', $item['id'], '</id>', PHP_EOL;
Hope this will help to those who need it.
Bye
-
Is there a way to duplicate my RSS feed (built in OSclass, no extra-feed thanks ;))?
Different partners need to have populated the xml output with different tags and I would like to offer one url for each of them.
http://www.example.com/feed_partner1
http://www.example.com/feed_partner2
...
-
Is there a way to duplicate my RSS feed (built in OSclass, no extra-feed thanks ;))?
Different partners need to have populated the xml output with different tags and I would like to offer one url for each of them.
http://www.example.com/feed_partner1
http://www.example.com/feed_partner2
...
Any tips to create more feed on my osclass website?