Page 1 of 1

[2.0/syndication] html-footer for feed

Posted: Sun Jun 22, 2014 6:27 pm
by bernd_d
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.

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

Posted: Mon Jun 23, 2014 12:49 am
by onli
I would think the easiest way would be to add an event into the tpl, in the core.

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

Posted: Mon Jun 23, 2014 10:32 am
by garvinhicking
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

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

Posted: Mon Jun 23, 2014 10:46 am
by onli
We had an event to emit code for/in every entry only while using it via rss?

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

Posted: Mon Jun 23, 2014 2:56 pm
by garvinhicking
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.

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

Posted: Mon Jun 23, 2014 5:00 pm
by onli
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 :)

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

Posted: Wed Jun 25, 2014 8:43 pm
by bernd_d
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?

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

Posted: Thu Jun 26, 2014 11:21 am
by garvinhicking
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

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

Posted: Thu Jun 26, 2014 5:44 pm
by bernd_d
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! :-)