How to create simple add-on that just modify template

Dadparvar

Well-known member
Hi,

I have lots of modifications to my templates, that if one day I decide to change them to default (or for any other reason I decide to back to its default mode), I should start reverting them all.

But if I do them by add-on, I can change it to default easily by disabling add-on.

Is there any sample code or tutorial? If anyone knows how to make such simple add-on, appreciated if you share its tutorial with us.

Thanks in advance
 
First you will have to place your developement forum in debug mode. Then you go to Template Modifications which can be found under the Appearances tab in your Admin Panel, click the Create New Template modification and fill in the fields there. But first you must also create an add on, so you can associate your template modifications with it.
 
First you will have to place your developement forum in debug mode. Then you go to Template Modifications which can be found under the Appearances tab in your Admin Panel, click the Create New Template modification and fill in the fields there. But first you must also create an add on, so you can associate your template modifications with it.
Thanks

I created an add-on. Then Clicked on "Create Template Modification".

In "Template" filed I should write the name of the template that I want to find a code and modify it? Or I should write a new unique name?
And how about "Modification Key"? And "Execution Order?

Thanks
 
Thanks

I created an add-on. Then Clicked on "Create Template Modification".

In "Template" filed I should write the name of the template that I want to find a code and modify it? Or I should write a new unique name?
And how about "Modification Key"? And "Execution Order?

Thanks

You are welcome :)

Yes for the Template field. About the Modification Key, simply enter a name. That can be unique for each template though. You can leave Execution Order to the default 10. But I would recommend that you use a higher value and not the same number if you modify the same template twice. I have encountered a weird problem in the past when I was hooking into the same template twice and both Execution Orders were 10.
 
Thanks.
Then How to associate it to add-on?

The very last value when creating a Template Modification says Add-on: Click on the drop down list, select the name of the add on that you have created, and click the Save Template Modification button.
 
You are most welcome. And congratulations with your first add on sir :)
Thanks for your kindness.

This template modification is about to change the CTA portal page layout to Grid view.
2016-01-09_01-55-51.webp
That @Gemma Taught me (in fact she did it. I just copied and pasted the codes. She made it). And I just made her tutorial as an add-on.
I'll share it as she let me. Although she Taught me in a public thread that you can see it.
 
Last edited:
Thanks for your kindness.

This template modification is about to change the CTA portal page layout to Grid view.
View attachment 125833
That @Gemma Taught me. And I just made her tutorial as an add-on.
I'll share it as she let me. Although she Taught me in a public thread that you can see it.

I am glad that I could be of help :)

I get an error message when I opened that link. Most likely it is closed to guests.
 
@wang
Would you please letting me know how to add an option to "Option" of ACP, then associate it to newly created add-on?
I want to Create an option that there is filed in it, where user can write HTML (better if be able to have editor there) on it, and then show its content somewhere in a template.
I understood how to create add-on and associate a template modification with that add-on, but how to read the content from a field in option (instead of writing directly in find field while modifying a template)? I want to have that field so that each time that we want to edit the content, easily edit the filed in option, in stead of editing the template modification.

I created an option group and associated it with the add-on.
Then I can add options for it.
Now what?

Thanks in advance
 
Last edited:
@wang
Would you please letting me know how to add an option to "Option" of ACP, then associate it to newly created add-on?
I want to Create an option that there is filed in it, where user can write HTML on it, and then show its content somewhere in a template.
I understood how to create add-on and associate a template modification with that add-on, but how to read the content from a field in option (instead of writing directly in find field while modifying a template)? I want to have that field so that each time that we want to edit the content, easily edit the filed in option, in stead of editing the template modification.

I created an option group and associated it with the add-on.
Then I can add options for it.
Now what?

Thanks in advance

Hello Dadparvar. Yes of course. You can use an option in templates, or in the template modifications, with this code,

HTML:
{$xenOptions.optionName}

optionName should contain the actual name of your own option that you have created.
 
Worked.

Thanks a lot. But how I can show a bigger field there? Now it shows a single line field.
EDIT: found. by adding "rows=5" in "Format Parameters".

And is it possible to use editor there? (Also HTML is not supported)

Thanks a lot
 
Last edited:
Worked.

Thanks a lot. But how I can show a bigger field there? Now it shows a single line field.
EDIT: found. by adding "rows=5" in "Format Parameters".

And is it possible to use editor there? (Also HTML is not supported)

Thanks a lot

You are welcome.

To support html you can use this code.

HTML:
{xen:raw $xenOptions.optionName}

To use the editor in options and to get it parsed, would need more extra code. You must have your view file where the editor code is parsed to be displayed correctly.
 
Top Bottom