Gaining basic data

How to get data to work with in your plugin


Every plugin-function can get data from the argument. There is only one argument for every function! It contains the full string from "<lb:yourfunctionname>... until ...</lb:yourfunctionname>"

Have a look at the following statement in the template:

Go to Mom’s Blog

And now the appropriate function:

function link_momsblog ($content) { }

The variable $content is a string that contains <lb:link_momsblog>Go to Mom’s Blog</lb:link_momsblog>


I’ve wrote a nice script that is meant to parse $content and put all attributes of the plugin into a handy array.

<lb:loop_mybooks author="Dan Brown" number="5"> ... </lb:loop_mybooks>

Here we have two attributes, author and number . Let’s see how we manage this in our function!

function loop_mybooks ($content) {
$att = getattributes($content);

Ah! getattributes() does the trick. $att is now an array with two fields. $att['author'] = "Dan Brown" and $att['number'] = "10"

Now you may use this attributes in your function. Don’t forget to define default values, if the user missed an important attribute!

Stripping Loudblog-Tags from $content

Now that we got the attributes out of our argument, we can kill those surrounding Loudblog-Tags. I’ve written a little function that does exactly this. It’s calles stripcontainer

Your $content might be:
<lb:link_momsblog>Go to Mom’s Blog</lb:link_momsblog>

Use this:
$content = stripcontainer($content);

Now your $content is:
Go to Mom’s Blog