Documentation

addPHPParser

void
oBXEditorUtils.addPHPParser(
   function handler[,
   int orderInd]
);

The method installs a handler to process PHP sessions of a HTML document.

A PHP handler processes the PHP inclusions before such are substituted with the PHP code icon in the visual editor. This happens at the document load time, and when switching from the HTML mode to visual mode.

Parameters

Parameter Description
handler Globally declared handler function.

A handler receives a string containing the PHP code. The handler function returns a string if any change took place, or false otherwise.

Note that the whole PHP island is passed to be processed, including the standard PHP open and close tags.
orderInd Handler priority; optional. By default, parsers are called in the same order they were previously registered in the system.

For example, if orderInd is 0, this handler will be called before calling any other PHP parsers. However, if another handler with orderInd of 0 gets registered later, it will become the first in the calling queue.

Example

function myPHPParser(str) { // If the PHP fragment is <?MyPHPFunction();?>, // it is replaced by the if (str=='<?MyPHPFunction();?>') icon return '<img src="icon.gif" title="Image Title" __bxtagname="customtag">'; return false; } //Add parser oBXEditorUtils.addPHPParser(myPHPParser);
© «Bitrix24», 2001-2024