- Tham gia
- 28/02/2015
- Bài viết
- 16,989
- Được Like
- 12,732
Vnxf.vn - 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 thread as 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.
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”.
Fill in the following fields and click on Save Add-on.
Next, go to Appearance -> Template Modifications and click on “Create Template Modification”
Fill in all the required fields.
In the Find box enter
In the Replace box enter
Click on “Test Modification” to validate that it works. You should see the following:
Click on “Save Template Modification”.
Next, got to Home -> Add-ons and export the add-on.
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.
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
In the Replace box enter
Phrases
Custom phrases can packaged into an add-on and referenced in templates.
Create the new phrase.
Add it to a template.
End result
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 thread as 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.
Mã:
$config['debug'] = true;
Fill in the following fields and click on Save Add-on.
Next, go to Appearance -> Template Modifications and click on “Create Template Modification”
Fill in all the required fields.
In the Find box enter
Mã:
#{xen:calc '{$post.position} + 1'}
In the Replace box enter
Mã:
#{xen:calc '{$post.position} + 1'}/{xen:calc '{$thread.reply_count} + 1'}
Next, got to Home -> Add-ons and export the add-on.
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.
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
Mã:
/^.*$/s
In the Replace box enter
Mã:
$0
/* Enter CSS entries */
Custom phrases can packaged into an add-on and referenced in templates.
Create the new phrase.
Nguồn: xenforo.com
Đính kèm
Bài viết liên quan
Được quan tâm
Bài viết mới