Loading...
 
Features / Usability

Features / Usability


Re: How to render HTML in Feed Description

posts: 214

I do not know a lot about rss feeds, but I have played around with the tiki rss feed programs before.

The "html" data you want, is passed as CDATA, and the CDATA is stored in the tiki_rss_items table in the "content" column.

The tiki rss plugin does not have any options to display the content data, and the tpl file the rss plugin uses, templates/wiki-plugins/wikiplugin_rss.tpl, does not access it.

I will explain how you can modify your copy of the tpl file to display the CDATA, but you need to be aware that if you do, you are opening an XSS vector, so be careful who's CDATA you display.

I recommend restricting the "content" display to this particular feed, because of the previously mentioned XSS, and because I have only tested this change with the "content" data in the rss feed you specified.

In the rss feed you are interested in, the "content" appears to be a duplication of the "description" data for this feed, so you would not need both.

This is the code that currently displays the description from the rss feed item in templates/wiki-plugins/wikiplugin_rss.tpl:

{if $item.description && $showdesc}

<div class="rssdescription">
{$item.description|escape}
</div>
{/if}

Below, I have added an "if" statement that checks if there is "content", if "showdesc" is on, and if the rssId is equal to your feed's rssId (you have to put your rssId into the code for it to work, replace the "333" with your feed's rssId). I also changed the original "if" to an "elseif".

{if $item.content && $showdesc && $item.rssId == 333}

<div class="rssdescription">
{$item.content}
</div>
{elseif $item.description && $showdesc}
<div class="rssdescription">
{$item.description|escape}
</div>
{/if}

If "showdesc" is on, and there is no "content" data for an item, or if it isn't your feed rssId, then it displays the item description as before. If there is "content" data for an item, it displays the "content" instead of the description.

I also have some other code related to external RSS feeds in Tiki that you might be interested in.

I have found that the external rss feed table, tiki_rss_items, grows constantly, there does not appear to be anything that gets rid of old rss feed data. The rss feed you are using seems to have lots of items, so your table could get huge. On my system I created a script to delete old rss feed items, and I scheduled a daily cron to run the script.

Here is the script that I am using to remove old rss feed items:

Copy to clipboard
#!/bin/sh # Begin /root/bin/clearExternalRSSfeeds # timestamp=`date --date="17 days ago" +%s`; /usr/bin/mysql -u (Your tiki database user) -p(Your tiki database user's password) --skip-column-names --batch --raw --execute="delete from (your tiki database name).tiki_rss_items where publication_date < $timestamp" # # End /root/bin/clearExternalRSSfeeds

This deletes old rss feed items for every external rss feed, so you may want to review your rss feeds and adjust the number of days you want to keep the data for.

if you would like confirmation that it is deleting old feed items, you could add code to email you the results of the mysql delete statement (Note: The "-v -v -v" is not a typo):

Copy to clipboard
/usr/bin/mysql -v -v -v -u (Your tiki database user) -p(Your tiki database user's password) --skip-column-names --batch --raw --execute="delete from (your tiki database name).tiki_rss_items where publication_date < $timestamp" | mail -s "Clearing old RSS feed items" (Your email address here)


And you also need a cron table entry that runs that script every day (mine is set to run at midnight):

Copy to clipboard
0 0 * * * /root/bin/clearExternalRSSfeeds >/dev/null 2>&1



Tom

There are no comments at this time.

Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting