Part 4: Power Coders

Exchanging data

If you need to pass information from one injection to another, inside the same content and priority, you can use the ´intra´ property, which gets reinitialized at the start of each new content processing.

If you need to pass information from one injection to another, outside the same content or priority, you can use the ´extra´ property, which gets initialized at creation time of the Nzymes engine.

Example.
This text is part of the WordPress Sample Page.

Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

To highlight some part of the text, you could do it like this:

Hi there! {[ .start() ]}I’m a bike messenger by day{[ .end() | .funny(1) ]}, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

The ´start´, ´end´, and ´funny´, custom fields could contain:

NameValue
start
$this->intra->xxx = strlen( $this->new_content );
end
$result = substr( $this->new_content, $this->intra->xxx );
$this->new_content = substr( $this->new_content, 0, $this->intra->xxx );
return $result;
funny
list( $text ) = $arguments;
return preg_replace( '/[aeiouy]/i', '<span style="color: red; font-weight: bold;">$0</span>', $text );

Here is what you’d get:

Hi there! I‘m a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)

The interesting thing is that those injections are now working exactly like HTML tags, meaning that they are completely portable. You can move them around in that content or copy and paste them into another one, and they continue to work without having to change anything.

Hi there! {[ .start() ]}I’m a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas.{[ .end() | .funny(1) ]} (And gettin’ caught in the rain.)

The content above will be shown like:

Hi there! I‘m a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin’ caught in the rain.)


Nzymes | WordPress Plugin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.