• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Custom BbCodes Framework [Deleted]

MOZ

Well-known member
#3
I going to ho ahead and reply in advance. I know this is probably going to be epic and very helpful like everything else you posted so far on this forum.
 

cclaerhout

Well-known member
#4
Useful codes

> To get the visitor object
PHP:
$visitor = XenForo_Visitor::getInstance();

> To get the XenForo Options object
PHP:
$options = XenForo_Application::get('options');
For example, if you want the board url after this, just use $options->boardUrl

> To use XenForo phrases
PHP:
$myPhrase = new XenForo_Phrase('MyPhrase');
If you get a phrase by this way, the phrase parameter "Cache this phrase globally" must be checked to prevent extra sql request

> To debug a variable
PHP:
Zend_Debug::dump($variableToCheck);
> To check if the content is an html image or a XenForo image attachment id
PHP:
    $regex_attach_direct_id = '#^\d+$#';
    $regex_attach_parsedimg = '#<img.+?src="(.+?)"#ui';
 
    if(preg_match($regex_attach_direct_id, $content, $id))
    {
        //Content is an id and should be an attachement id
        $content = XenForo_Link::buildPublicLink('attachments', array('attachment_id' => $id[0]));
    }
    elseif(preg_match($regex_attach_parsedimg, $content, $src))
    {
        //Content is a img url
        $content = $src[1];
    }

> To get a XenForo display property
PHP:
$myXenProperty = XenForo_Template_Helper_Core::styleProperty('myXenProperty');
$marginright = XenForo_Template_Helper_Core::styleProperty('myXenProperty.margin-right');
I'm also using my own helper to get the color format I want for a property. See the code here.