Parser

Introduction

Use the following to retrieve the parser class object.

$tp = e107::getParser();

Parser methods

toHTML()

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

$tp->toHTML($text, $parseBB = false, $modifiers = '', $postID = '', $wrap = false)
Parameter
Type
Description
Mandatory?

text

string

text or HTML to be parsed

Yes

bparseBB

boolean

set to true to parse BBcodes into HTML

No

modifiers

string

Choose from pre-defined Parser modifiers.

No

postID

No

wrap

boolean

Default: false

No

Example

$tp->toHtml("<strong class="bbcode bold bbcode-b bbcode-b-page">Bold print</strong>", true, 'BODY'); 

toDate()

Convert a UNIX timestamp into a readable format.

Parameter
Type
Description
Mandatory?

datestamp

unix timestamp

Yes

format

string

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" Default: short

toText()

Convert html to plain text.

createConstants()

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

replaceConstants()

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

parseTemplate()

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

Parameter
Type
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.

setThumbSize()

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

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.

Advanced settings:

toIcon()

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

toAvatar()

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

toImage()

Render an image.

lanVars()

Used for substitution of variables, in language files for example.

Parser options

TODO: Convert below code into readable tables with proper descriptions

Parser modifiers

TODO: Convert below code into readable tables with proper descriptions

Last updated

Was this helpful?