Hi,
I’m trying to write a very basic plugin to format some text as such:
{exp:text_format:uppercase}Hello{/exp:text_format:uppercase}I have created the plugin as per the user guide, and have the following method:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Text_format
{
var $return_data = '';
function Text_format()
{
$this->EE =& get_instance();
}
function uppercase()
{
$this->EE =& get_instance();
$this->return_data = strtoupper($this->EE->TMPL->tagdata);
}
function lowercase()
{
$this->EE =& get_instance();
$this->return_data = strtolower($this->EE->TMPL->tagdata);
}
function uppercase_first()
{
$this->EE =& get_instance();
$this->return_data = ucfirst($this->EE->TMPL->tagdata);
}
function uppercase_words()
{
$this->EE =& get_instance();
$this->return_data = ucwords($this->EE->TMPL->tagdata);
}
function usage()
{
}
}But nothing gets returned. What am I doing wrong?
My bad - just noticed methods, other than the constructor can return directly.
This leads me onto another problem…
If I use a global variable like so:
{exp:text_format:uppercase}{a_global_var}{/exp:text_format:uppercase}and return that, it breaks, as the plugin is simply upper casing the tag, rather than the content the tag returns…
Is there anyway around this?
An optional way around this would be to check to see if the var passed to the plugin is, in fact, a global variable and parse it yourself before uppercasing it. I’m not sure how necessary this is since you’re working with a demo plugin.
Do you have a specific need to manipulate global variables within a plugin?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.