No promises but give this a go :
<?php
/*
=========================================================================
Copyright (c) 2011 Mark Bowen Design
=========================================================================
File: pi.explode_first_name.php V2.0
-------------------------------------------------------------------------
Purpose: Find persons first name by exploding on a space
in the {screen_name}
=========================================================================
CHANGE LOG :
29th March 2011
- Version 1.0
- Creation of initial plugin
=========================================================================
*/
$plugin_info = array(
'pi_name' => 'Explode First Name',
'pi_version' => '1.0',
'pi_author' => 'Mark Bowen',
'pi_author_url' => 'http://www.markbowendesign.com/',
'pi_description' => 'Find persons first name by exploding on a space in the {screen_name}',
'pi_usage' => Explode_first_name::usage()
);
class Explode_first_name {
var $return_data = "";
function Explode_first_name()
{
$this->EE =& get_instance();
$tagdata = $this->EE->TMPL->tagdata;
$screen_name = $this->EE->session->userdata['screen_name'];
$parts = explode(" ", $screen_name);
$first_name = $parts[0];
$last_name = $parts[1];
foreach ($this->EE->TMPL->var_single as $key => $val)
{
if ($key == "first_name")
{
$tagdata = $this->EE->TMPL->swap_var_single($key, $first_name, $tagdata);
}
if ($key == "last_name")
{
$tagdata = $this->EE->TMPL->swap_var_single($key, $last_name, $tagdata);
}
}
// Spit it out
$this->return_data = $tagdata;
}
// END
// ----------------------------------------
// Plugin Usage
// ----------------------------------------
// This function describes how the plugin is used.
// Make sure and use output buffering
function usage()
{
ob_start();
?>
A nice easy one this one!
{exp:explode_first_name name="Mark Bowen"}
{first_name}{last_name}
{/exp:explode_first_name}
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
// END
}
// END CLASS
/* End of file pi.explode_first_name.php */
/* Location: ./system/expressionengine/third_party/explode_first_name/pi.explode_first_name.php */
Usage
{exp:explode_first_name}
{first_name}, {last_name}
{/exp:explode_first_name}
Will need to go into a file called pi.explode_first_name.php in a folder called explode_first_name like this :
system > expressionengine > third_party > explode_first_name > pi.explode_first_name.php
Best wishes,
Mark