[2.0/syndication] html-footer for feed

Discussion corner for Developers of Serendipity.
Post Reply
bernd_d
Regular
Posts: 466
Joined: Thu Jun 03, 2010 9:28 am
Contact:

[2.0/syndication] html-footer for feed

Post by bernd_d » Sun Jun 22, 2014 6:27 pm

Currently it is not possible for users to include some html-code to every feed-entry (like a footer). For example this could be contact informations like twitter/facebook or (in my case) html-code to track/count rss-readers within piwik.

Currently i always have to modify tpl-files to include this and changes are gone again after updating.

Don't know if it simply could be included within syndication-plugin or if there have to be some more changes within core or has to be implemented directly into core.

User avatar
onli
Regular
Posts: 2220
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0/syndication] html-footer for feed

Post by onli » Mon Jun 23, 2014 12:49 am

I would think the easiest way would be to add an event into the tpl, in the core.

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0/syndication] html-footer for feed

Post by garvinhicking » Mon Jun 23, 2014 10:32 am

onli wrote:I would think the easiest way would be to add an event into the tpl, in the core.
We actually already have an event for that; however the syndication plugin does not have an event plugin counterpart, and I wouldn't want to add an event plugin solely for this reason.

I think the "nearest" plugin for this functionality is the serendipity_event_page_nugget (spartacus) one, to which I've added this functionality now in version 1.11. This will also work in older Serendipity versions.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2220
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0/syndication] html-footer for feed

Post by onli » Mon Jun 23, 2014 10:46 am

We had an event to emit code for/in every entry only while using it via rss?

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0/syndication] html-footer for feed

Post by garvinhicking » Mon Jun 23, 2014 2:56 pm

onli wrote:We had an event to emit code for/in every entry only while using it via rss?
Yip, you can see it in the commit. The "frontend_display" entry specifies an $addData array index that allows you to see if it's called from the RSS feed or not.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2220
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0/syndication] html-footer for feed

Post by onli » Mon Jun 23, 2014 5:00 pm

Ok. That is different than what I expected, but seems like it indeed should solve bernds problem. For the log, that is in https://github.com/s9y/additional_plugi ... b3c7aec977. Thanks :)

bernd_d
Regular
Posts: 466
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: [2.0/syndication] html-footer for feed

Post by bernd_d » Wed Jun 25, 2014 8:43 pm

garvinhicking wrote:I think the "nearest" plugin for this functionality is the serendipity_event_page_nugget (spartacus) one, to which I've added this functionality now in version 1.11.
I've tried it and works as it should, thank you!

Another question to this plugin, as i already asked you on twitter: What about smarty within page_nugget? Currently it is not possible to use it and you said you could "hack" something for me. But wouldn't it be useful to have a checkmark within this plugin "use smarty"? In this case, everyone could use it very easy to include informations, even from plugins.

Our is this to difficult/dangerous for average users? Or is it not possible to parse smarty from within the html-field?

User avatar
garvinhicking
Core Developer
Posts: 30014
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0/syndication] html-footer for feed

Post by garvinhicking » Thu Jun 26, 2014 11:21 am

Hi!

It isn't that easy, actually. Parsing smarty consists of several steps to setup a fake "file", because you cannot easily parse a single variable. For that, the serendipity_event_smartymarkup event plugin exists. It supports parsing HTML nuggets. The Page nugget is also considered a "HTML nugget", so when you enable smarty markup parsing for HTML nuggets, also page nuggets should be parsed.

However, using smartymarkup is really not the best thing to do for its overhead, if all you want is to output the entry title inside RSS.

Instead, I would create this simply event plugin:

Code: Select all

<?php
class serendipity_event_rss_bauigel extends serendipity_event {
    function introspect(&$propbag) {
        global $serendipity;

        $propbag->add('name',          'Bauigel: RSS');
        $propbag->add('description',   '');
        $propbag->add('author',        'Garvin');
        $propbag->add('version',       '0.1');
        $propbag->add('requirements',  array('serendipity' => '1.7', 'smarty' => '2.6.7', 'php' => '5.2.0'));
        $propbag->add('event_hooks',   array('frontend_display' => true));
    }

    function generate_content(&$title) {
        $title = 'Bauigel: RSS';
    }

    function event_hook($event, &$bag, &$eventData, $addData = null) {
        global $serendipity;

        $hooks = &$bag->get('event_hooks');

        // RSS-Feed special case
        if ($event == 'frontend_display' && $addData['from'] == 'functions_entries:printEntries_rss') {
            // TODO: Insert your HTML code here. Use $eventData[...] to access variable of your entry.
            $eventData['body'] .= 'RSS-Feed: Der Titel ist "' . $eventData['title'] . '"';
            return true;
        }
    }
}
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

bernd_d
Regular
Posts: 466
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: [2.0/syndication] html-footer for feed

Post by bernd_d » Thu Jun 26, 2014 5:44 pm

garvinhicking wrote:serendipity_event_smartymarkup
No, thank you. I had to many problems with this plugin in earlier times. :evil:
garvinhicking wrote:Instead, I would create this simply event plugin:
I'll try it at weekend. Thanks in advance! :-)

Post Reply