Classes and Methods Using e107's built-in classes and methods.

Parser

toHtml()

Parse HTML in various ways. eg. replace constants, convert bbcode etc.

$tp->toHtml(string, bbcodes, type);
$tp->toHtml("<strong class="bbcode bold bbcode-b bbcode-b-page">Bold print</strong>", true, 'BODY'); // Example
Name Description
string text or HTML to be parsed
bbcodes boolean - set to true to parse bbcodes into html
type string - TITLE, SUMMARY, DESCRIPTION, BODY, LINKTEXT, RAWTEXT

toDate()

Convert a unix timestamp into a readable format.

$tp->toDate(unixDatestamp, format);
Format Description
short Short date format as defined in admin preferences
long Long date format as defined in admin preferences
relative Relative time format. eg. "2 days ago"

toText()

Convert html to plain text.

$tp->toText(string);

createConstants()

Convert e_xxxxx paths to their equivalent shortcodes. eg. e_PLUGIN becomes {e_PLUGIN}

$tp->createConstants(string);

replaceConstants()

Convert {e_XXXX} shortcode paths to their equivalent constants. eg. {e_PLUGIN} becomes e_PLUGIN

$tp->replaceConstants(string);

parseTemplate()

Parse an e107 template using core and/or custom shortcodes. ie. replaces all instances of {XXXXX_XXXX} etc.

$tp->parseTemplate(template, use core shortcodes, custom shortcodes);
Name Description
template string
user core shortcodes boolean
custom shortcodes object

thumbUrl()

Use to convert {e_MEDIA_IMAGE} and other image paths to an auto-sized image path for use inside an img tag.

$url = "{e_MEDIA_IMAGE}2012-04/someimage.jpg";
$image = $tp->thumbUrl($url);
echo "<img src='".$image."' />

setThumbSize()

Set the width, height and crop of the thumbUrl function.

$tp->setThumbSize($width, $height, $crop);

toGlyph()

Convert a glyph name into Html. Just choose an icon from font-awesome and remove the first 'fa'
Templates may also use the following shortcode: which calls the same function.

$tp->toGlyph("fa-anchor");


Advanced settings:

$tp->toGlyph("fa-anchor", array('size'=>'2x'));

toIcon()

Render an icon. If a .glyph extension is found, it will automatically use the toGlyph() function above.

$iconPath = "{e_MEDIA}myicon.png";
$tp->toIcon($iconPath);

toAvatar()

Render a user avatar. If empty, the current user's avatar will be displayed if found or a generic avatar image.

echo $tp->toAvatar(); // render avatar of the current user. 
$userData = e107::user(5);  // Get User data for user-id #5. 
echo $tp->toAvatar($userData); // requires as a minimum $userData['user_image'].

toImage()

Render an image.

$url = "{e_MEDIA_IMAGE}2012-04/someimage.jpg";
$parms = array('w'=>500, 'h'=>200,'crop'=>1, 'alt'=>'my image'); // if not width/height set, the default as set by {SETIMAGE} will be used.
echo $tp->toImage($url,$parms); 

Thursday 03 March 2016 - 15:08:00 admin,