Introduce yourself here! In order to avoid spam, new users must first comment on the discussion in the 'Introductions' before they become 'full members'
Execution backwards?
  • I wanted to write a simple counter plugin. If I have a document with numbered point, like

    1. First paragraph
    2. Second item
    3. Third line

    how nice would it be if I needn’t to bother with the numbers, so if I insert additional items in the line I haven’t to renumber subsequent entries myself. So, let’s write a plugin that takes

    [ct]. First paragraph
    [ct]. Second item
    [ct]. Third line

    and at each appearance of [ct], inserts a counter that’s automatically increasing. I wrote this:

    function plugin_count($action, $attributes, $content, $params, $node_object)
    {
    if($action=='validate') return true;

    global $plugincount_counter;

        if($attributes['default']!='')
        {
        $plugincount_counter=$attributes['default'];
            return $content;
        }

    return ++$plugincount_counter.$content;

    }

    This handles even a tag [ct=number] to reset the counter. And the numbers appear backwards.

    3. First paragraph
    2. Second item
    1. Third line

    Is the BBCode evaluated right to left? If so, how to deal with the situation?
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!