Custom BB Code

There is a separate directory for js files, which is typically where you would place them.
All PHP files typically go in the library directory.

CSS files are not stored in the file server.
 
the class file goes in library directory, java script files will be in "js" folder (some subfolder), and CSS stored in database? This is the general rule for directory structure of an addon?
Yes, that is the standard practice.
 
If a variable contains HTML, you can get it to bypass the escaping we do like this:
Code:
{xen:raw $whateverParam}
 
Yes, almost working...

Now the images has loaded, but i think this:
Code:
<xen:require css="custom/folder/custom.css" />

doesn't loading like the JS file.

The CSS can be loaded like JS file, from external file? Is absolutely necessary to copy-pase the file as CSS template in database?
 
The CSS is stored as a template in the database and referenced by the template name rather than a path to an external file. It's not strictly necessary, but highly recommended and standard practice. It lets XF take care of concatenation and minification.
 
I really would recommend, like Jeremy P, CSS being stored in the database and being called as per your example.

There is an alternative solution.
Code:
<xen:container var="$head.someUniqueKeyName">
    <link rel="stylesheet" href="custom/folder/custom.css" />
</xen:container>
This calls the stylesheet in the traditional way, from an external file, but it will be added to the head params of the page container.
 
Following this model, class loading system (name convention), template syntax... i can do all kind of tools (not just custom bbcodes).... like i did in phpBB. I must rewrite all in this way.

I will need an example of using database connection (read/write). I guess it's also a class in library/XenForo.
 
PHP:
$database = \XenForo_Application::getDb()
... will return the database object, a \Zend_Db_Adapter instance I believe. From there you can call things like $database->query(), etc.

http://framework.zend.com/manual/1.11/en/zend.db.adapter.html#zend.db.adapter.select and poking around the XenForo code will show you what more you can do with it.

For most CRUD uses, I'd recommend the use of Model and DataWriter classes instead of using the database object directly. For those you create classes that extend \XenForo_Model and \XenForo_DataWriter respectively, and you can base their contents on the built in classes.
 
Hello,
for a BBCode with class/function callback, the only param is a URL.
in $tag["children"][0] i got: url Array Array
but when trying to use $tag["children"][0][0], there is nothing.

How can i get the passed URL?

Thanks!

LE: nevermind... when i put URL as content of a BBCode, when saving, xenforo parse that and put URL bbcode enclosure...
I droped the http.... from parameter.
 
Last edited:
Top Bottom