21293 Posts in 5733 Topics by 2602 members
| Go to End | Next > | |
| Author | Topic: | 2039 Views |
-
Rss Link

5 January 2011 at 8:45pm
Hi!
I need ti change default link of RssFeed.
I create a function that ask data to external db. so at the and of my function have:function query_ext() {
......query thak extract data ....
$doSet = new DataObjectSet();
while (...){
$result = array(
'Title'=> $titolo,
'Abstract'=> $abstract,
'My_Link'=> $my_link, );
$doSet->push(new ArrayData($result));}
return $doSet;
}and I wrote this in my controller:
function rss() {
$rss = new RSSFeed($this->query_ext(), 'My_Link', "I Feed RSS", "My feed are:", "Title", "Abstract", "Author");
$rss->outputToBrowser();
}In my rss page I see title and abstract but not link. can you help me to find error?
-
Re: Rss Link

6 January 2011 at 8:58pm
The link parameter which you have used for My_Link is for the link to the RSS feed not each item in particular. I believe RSSFeed would assume that all entries are subclasses of DataObject and have either AbsoluteLink() or Link() functions defined. Try change My_Link to Link in your while loop and see if it picks up 'Link' by default, otherwise you will need to define a actual dataobject class for it.
-
Re: Rss Link

27 January 2011 at 11:52pm
Hi Willr!
I try to change My_link in Link but nothing change.
Can you help me to create a correct function? I'm unable to solve this problem..
Thnaks! -
Re: Rss Link

28 January 2011 at 9:46am
I try to change My_link in Link but nothing change
Try AbsoluteLink(). It is possible that it won't work at all if it calls the method since of course your object isn't an dataobject. You may have to create those objects as DataObject subclasses for it to call Link() on.
-
Re: Rss Link

31 January 2011 at 8:56pm Last edited: 31 January 2011 11:49pm
Hi Willr..
sorry but I'm unable to correct my example..
I try in this way
$result = array(
'Title'=> $titolo,
'Abstract'=> $abstract,
'mylink'=> $id, );
$doSet->push(new ArrayData($result));function rss() {
$rss = new RSSFeed($this->solr_ss(), $this->Link(), "I Feed RSS", "Article:", "Title", "Abstract", "mylink","Author");
$rss->outputToBrowser();
}In RssFeed.php I add a field $mylinkField
and in .ss
<% control Entries %>
<item>
<title>$Title.XML</title>
<link>$AbsoluteLink</link>
<% if Description %><description>$Description.AbsoluteLinks.EscapeXML</description><% end_if %>
<% if Mylink %><mylink>$mylink</mylink><% end_if %>
<% if Date %><pubDate>$Date.Rfc822</pubDate>
<% else %><pubDate>$Created.Rfc822</pubDate><% end_if %>
<% if Author %><dc:creator>$Author.XML</dc:creator><% end_if %>
<guid>$AbsoluteLink</guid>
</item>
<% end_control %>
I can see link in the example but if i put:
<link>$mylink</link>
I enter always in user_error.. -
Re: Rss Link

4 February 2011 at 3:42pm
Hi Bebabeba,
Have you tried looking at the code for RSSFeed? This is the function which generates the $AbsoluteLink string you posted in your template example.
function AbsoluteLink() {
if($this->failover->hasMethod('AbsoluteLink')) return $this->failover->AbsoluteLink();
else if($this->failover->hasMethod('Link')) return Director::absoluteURL($this->failover->Link());
else user_error($this->failover->class . " object has either an AbsoluteLink nor a Link method. Can't put a link in the RSS feed", E_USER_WARNING);
}As you can see it calls hasMethod(). I am not sure if hasMethod() will pick up the fact that you have an array of data (rather than an object).
So what I think you need to do, as I mentioned in my first post is to use a proper object rather than simply an Array.
// new class - RSSFeedableData.php
class RSSFeedableData extends ArrayData {function Link() { return $this->getField('Link'); }
}// change your function like
$result = array(
'Title'=> $titolo,
'Abstract'=> $abstract,
'Link'=> $id
);$doSet->push(new RSSFeedableData($result));
...
| 2039 Views | ||
| Go to Top | Next > |


