For implementing some short-codes (e.g. footnote), it would be great to have functions that could be called before/after the filtering has been done.

For example,

  $shortcodes['footnote'] = array(
    'title' => t('Footnote'),
    'description' => t('Generate a footnote'),
    'process callback' => 'module_shortcode_footnote',
    'post-process callback' => 'module_shortcode_footnote_cleanup'
    );

would call module_shortcode_footnote_cleanup that would display the footnotes automatically at the end of the filtered text.

I attach a patch (against 7.x-2.x) to provide such a functionality.

Comments

barrett’s picture

Status: Active » Needs review
StatusFileSize
new1.79 KB

The previous patch does not apply successfully on the 7.x-2.x-dev branch. I've rerolled against that branch.

@bpiwowar, I'm still not clear on the use-case though. Can you provide some sample code for the footnote case you discussed? Hopefully seeing what that would do will help me grok what you're wanting to accomplish.

denes.szabo’s picture

Assigned: Unassigned » denes.szabo

I like this idea, I would welcome a good (and easy) footnote solution.

I am checking this contributed code, then I will merge. Soon.

bpiwowar’s picture

StatusFileSize
new2.95 KB

The post process callback allows to display all the footnotes at the end of the post (there could be a short-code to call it explicitly that would avoid using a post-process hook, but it is easier for end-users to hide this).

I attach the code related to footnote handling in my module to give an idea of how I use the post-process hook

denes.szabo’s picture

Assigned: denes.szabo » Unassigned
Status: Needs review » Needs work

@bpiwowar - You named the functions pre and post process, but the code add pre and post text to the filtered text. These functions should do pre and post process things with the whole text, maybe it's a special case when add additional text to the original.