Creating a Template Based Add-On

Unmaintained Creating a Template Based Add-On 1.0.0

No permission to download
Compatible XF 1.x versions
  1. 1.2
  2. 1.3
  3. 1.4
  4. 1.5
If you need to edit a XenForo template, you can either edit the template directly or use the built-in template modification system. With the template modification system, you can package template modification(s) as an add-on, export it from the source forum and import it into different forums or share the template modifications with others.

This tutorial will go over how to package a template modification as an add-on and will use the template modification suggested by Syndol in this threadas an example.

The first thing that needs to be done is to set the forum in debug mode.

Open up “library\config.php” and add the following line of code and save the file.

Code:
$config['debug'] = true;

1.webp


Now that the forum is in debug mode, you can create an add-on. Go to Home -> Add-ons and click on “Create Add-on”.
2.webp


Fill in the following fields and click on Save Add-on.
3.webp

Next, go to Appearance -> Template Modifications and click on “Create Template Modification”
4.webp


Fill in all the required fields.

In the Find box enter
Code:
#{xen:calc '{$post.position} + 1'}

In the Replace box enter

Code:
#{xen:calc '{$post.position} + 1'}/{xen:calc '{$thread.reply_count} + 1'}

5.webp


Click on “Test Modification” to validate that it works. You should see the following:
6.webp


Click on “Save Template Modification”.

Next, got to Home -> Add-ons and export the add-on.
7.webp


You can now import this add-on into another forum just like you import any other add-on.

The end result, which you can download here.
8.webp


Additional Modifications

The following are examples of additional modifications that can be packaged into an add-on

Template Conditionals

In this example, a template conditional will be added around a block of code.

In the Find box, add the entire block of code that you want to surround with the template conditional.

In the Replace box, the content of the Find box can be referenced by the $0 variable. This makes it very convenient to add the conditional statement around the block of code.
11.webp

This block of code will not be shown in forums with IDs of 3, 40 and 111.

EXTRA.CSS

You can add entries to EXTRA.CSS and package them as an add-on.

Set the Search Type to "Regular Expression"

In the Find box enter
Code:
/^.*$/s

In the Replace box enter
Code:
$0
/* Enter CSS entries */

10.webp


Phrases

Custom phrases can packaged into an add-on and referenced in templates.

Create the new phrase.
upload_2014-6-22_10-29-33.webp


Add it to a template.
upload_2014-6-22_10-30-46.webp


End result
upload_2014-6-22_10-31-32.webp
Author
0ptima
Downloads
46
Views
1,448
First release
Last update

Ratings

5.00 star(s) 3 ratings

More resources from 0ptima

Latest reviews

I'm reviewing this so it's easier for me to find in the future, I always struggle to find it on google :)
Awesome step by step tutorial, that helps even those who didn't code yet to be bale to create an add-on. Clear enough. Hope to see more advanced tutorials (like add-ons with style properties options and ...).
Fantastic, This is what i am looking for :) since a while.
Top Bottom