Resource icon

Template Modification System (TMS) 1.3.1

No permission to download
I would agree that such functional should be in the core.
But I would disagree that it's undesirable to use in other addons (it was created exactly for this).
As Nathan mentioned, on-compilation manipulations better for performance than on-fly.
Also, sometimes there are no template hooks in needed locations. And developers don't add new template hooks during several releases.
Of course you can use template_post_render event with preg_replace to edit final html. But again, this is horroble for performance and breaks MVC pattern.

Every software uses some dependencies. XenForo uses Zend Framework, Sabre, jQuery, ElasticSearch.
Addons use Diff libs, Syntax Highlighting libs and XenForo itself :)

Ideally TMS would be natively adopted by XenForo, either that or having a bare basic implementation that addon developers can bundle with their addons in case the end-user does not have TMS installed.
First, I'm ready to implement it voluntarily (send patches, test, etc..).
Second, if you talk about portable version of TMS, we can just include TMS-installer to every other addon so that first will be installed TMS, then needed addon.

thats probably the worst thing ever, particularly for nondevelopers. the master style is hidden by default for a reason.
I mean master modifications, everythingelse (templates, properties) of course should be hidden for non-developers.
The sense of master modification is patch to all the styles. It's comletely different than master template which is for developeres.
Templates are hidden since they are needed for backup but backup of modification = it's removal.
 
First, I'm ready to implement it voluntarily (send patches, test, etc..).
Second, if you talk about portable version of TMS, we can just include TMS-installer to every other addon so that first will be installed TMS, then needed addon.

This sounds like a good compromise, you're saying bundle TMS with whatever addon is being offered, and hook the installation into that of the actual addon, so that the end-user only installs one addon from their perspective?

Edit:

Also just to be clear; I'm not saying it's undesirable to use in other addons, it certainly is desirable. I'm saying the dependency (and added complexity for users installing an addon) it imposes is undesirable.
 
Yeah, agree. It adds a complexity in installation.
So portable version will be actually the same tms but attached to another addon.
I just have to find a way to make this integration easy for developers.
They have to put tms in the library, add some code to installer and it's done.
In one word have to make auto-install instruction.
 
From a user standpoint I'm willing to install another addon if this addon provides broader support for both template edits and other addon installations. So far TMS has saved me from at least 10 nasty template edits and other addon template edit requirements. That said, I agree with Natan, this addon would be a great asset for XenForo if it were in its core. Until then I look and ask for addon authors to work with TMS frequently.
 
Yeah, agree. It adds a complexity in installation.
So portable version will be actually the same tms but attached to another addon.
I just have to find a way to make this integration easy for developers.
They have to put tms in the library, add some code to installer and it's done.
In one word have to make auto-install instruction.

Yes, and you'll have to do a check to see if it isn't already installed.

It'll be up to developers to ensure their addon always works with the latest TMS, but I'm guessing you're already doing your best to stay backward compatible as much as possible to prevent any conflicts.
 
From a user standpoint I'm willing to install another addon if this addon provides broader support for both template edits and other addon installations.
I agree. TMS as a stand alone add-on provides much more flexibility to the end user, and makes it much easier to provide support and uniform version updates.
 
I used to customize PAGE_CONTAINER template quite a bit to get the things done that I wanted. It was a major pain every time XF was updated, I just did not feel like keeping it updated... TMS is here now! Thank you
 
Bug found...

* Imported some TMS definitions successfully.
* Later created some definitions myself.
* Inadvertently gave 2 of them the same Modification ID the imported template definitions (working with the same template) already have.

What happened was NOT that I got an error at my creation of the definitions.
They got saved successfully and simply silently ignored the former imported definitions with the same ID which went also silently out of sight in the Template Modifications screen in ACP.

I edited the Modification IDs of the newly created definitions and the imported ones came magically back and got applied again.

Maybe you can look at this... :)
 
How could you gave them same Modification ID? It is checked before saving.
Could you repeat the same procedure or simplify as much as possible?
Or could you make screencast of your actions? I have to figure out how to reproduce your actions.
 
You can recreate it always and without problems. It seems the check for double IDs does not include imported template modifications or omits the check if the new modification with the same ID modifies the same template...
  1. You can reproduce it easily, for example:
  2. Install the AddOn "Xenforo Open Framework 1.0" as it includes 18 template edits.
    One of them has the ID "nvt001".
  3. Create a new template modification at template "navigation_visitor_tab" sand name it also "nvt001".
You will see that the first (imported) modification will silently get removed from the list of modifications and will not be applied any more. Only the new template modification will be shown and will get applied.

If you change the ID of the new modification OR delete it the first modification reappears magically and will again get applied.

Funny bug. ;)
 
I have tried it and it worked as expected.
For what style have you created the mod?
You can create child modifications as well as child templates.
And they will rewrite parent ones.
 

Attachments

  • Screenshot_37.webp
    Screenshot_37.webp
    21.9 KB · Views: 14
Okay, this is not bug, this seems to be a feature.
But there really should be a notice or an alert if that happens. ;)

It seems that imported template modifications are applied against the Master Style and are inherited by all installed styles. If you make a modification in the Default style (as most web masters will do) and give it the same ID the modification of the master style is silently ignored.

Again, there should be a notice at least or the check for same ID should include ALL modifications made against ALL styles. Otherwise you never can be sure that imported modifications will get silently ignored and lead to serious and very hard to detect problems ...

Thank you for your work with that valuable AddOn!
 
Yeah have to think about some notification.
Mods actually are bit different from templates since you can't create template for custom style without having it for master.
Thanks for reporting!
 
I can't activate a template edit and getting this error:

XenForo_Template_Compiler_Exception: Line 9: Cannot have content-checking if tag without a contentcheck part. - library/XenForo/Template/Compiler.php:983

#0 /home/user/public_html/library/XenForo/Template/Compiler/Tag/If.php(138): XenForo_Template_Compiler->getNewCompilerException(Object(XenForo_Phrase), 9)
#1 /home/user/public_html/library/XenForo/Template/Compiler.php(638): XenForo_Template_Compiler_Tag_If->compile(Object(TMS_Template_Compiler), 'if', Array, Array, Array)
#2 /home/user/public_html/library/XenForo/Template/Compiler.php(567): XenForo_Template_Compiler->compileTag('if', Array, Array, Array)
#3 /home/user/public_html/library/XenForo/Template/Compiler.php(506): XenForo_Template_Compiler->compileSegment(Array, Array)
#4 /home/user/public_html/library/XenForo/Template/Compiler/Tag/If.php(107): XenForo_Template_Compiler->compileSegments(Array, Array)
#5 /home/user/public_html/library/XenForo/Template/Compiler.php(638): XenForo_Template_Compiler_Tag_If->compile(Object(TMS_Template_Compiler), 'if', Array, Array, Array)
#6 /home/user/public_html/library/XenForo/Template/Compiler.php(567): XenForo_Template_Compiler->compileTag('if', Array, Array, Array)
#7 /home/user/public_html/library/XenForo/Template/Compiler.php(506): XenForo_Template_Compiler->compileSegment(Array, Array)
#8 /home/user/public_html/library/XenForo/Template/Compiler/Tag/If.php(107): XenForo_Template_Compiler->compileSegments(Array, Array)
#9 /home/user/public_html/library/XenForo/Template/Compiler.php(638): XenForo_Template_Compiler_Tag_If->compile(Object(TMS_Template_Compiler), 'if', Array, Array, Array)
#10 /home/user/public_html/library/XenForo/Template/Compiler.php(567): XenForo_Template_Compiler->compileTag('if', Array, Array, Array)
#11 /home/user/public_html/library/XenForo/Template/Compiler.php(506): XenForo_Template_Compiler->compileSegment(Array, Array)
#12 /home/user/public_html/library/XenForo/Template/Compiler.php(369): XenForo_Template_Compiler->compileSegments(Array)
#13 /home/user/public_html/library/TMS/Template/Compiler.php(63): XenForo_Template_Compiler->compileParsed(Array, 'sidebar_online_...', 0, 0)
#14 /home/user/public_html/library/TMS/Model/Template.php(36): TMS_Template_Compiler->modifyAndParse('sidebar_online_...', 28, 9498)
#15 /home/user/public_html/library/TMS/Model/Template.php(159): TMS_Model_Template->getEffectiveTemplateByTitle('sidebar_online_...', 28)
#16 /home/user/public_html/library/XenForo/Model/Template.php(1014): TMS_Model_Template->compileAndInsertParsedTemplate(4026, Array, 'sidebar_online_...', 28)
#17 /home/user/public_html/library/XenForo/Model/Template.php(986): XenForo_Model_Template->compileTemplateInStyleTree(Array)
#18 /home/user/public_html/library/TMS/DataWriter/Modification.php(212): XenForo_Model_Template->compileMappedTemplatesInStyleTree(Array)
#19 /home/user/public_html/library/TMS/DataWriter/Modification.php(182): TMS_DataWriter_Modification->_recompileAssociatedTemplates()
#20 /home/user/public_html/library/XenForo/DataWriter.php(1385): TMS_DataWriter_Modification->_postSave()
#21 /home/user/public_html/library/XenForo/ControllerAdmin/Abstract.php(126): XenForo_DataWriter->save()
#22 /home/user/public_html/library/TMS/ControllerAdmin/Modification.php(238): XenForo_ControllerAdmin_Abstract->_getToggleResponse(Array, 'TMS_DataWriter_...', 'template-modifi...')
#23 /home/user/public_html/library/XenForo/FrontController.php(310): TMS_ControllerAdmin_Modification->actionToggle()
#24 /home/user/public_html/library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#25 /home/user/public_html/admin.php(13): XenForo_FrontController->run()
#26 {main}

array(3) {
["url"] => string(65) "http://www.site.com/admin.php?template-modifications/toggle"
["_GET"] => array(1) {
["template-modifications/toggle"] => string(0) ""
}
["_POST"] => array(8) {
["filter"] => string(0) ""
["exists"] => array(18) {
[16] => string(1) "1"
[11] => string(1) "1"
[15] => string(1) "1"
[14] => string(1) "1"
[13] => string(1) "1"
[10] => string(1) "1"
[9] => string(1) "1"
[17] => string(1) "1"
[12] => string(1) "1"
[31] => string(1) "1"
[32] => string(1) "1"
[33] => string(1) "1"
[34] => string(1) "1"
[22] => string(1) "1"
[23] => string(1) "1"
[24] => string(1) "1"
[25] => string(1) "1"
[26] => string(1) "1"
}
["id"] => array(12) {
[16] => string(1) "1"
[11] => string(1) "1"
[10] => string(1) "1"
[9] => string(1) "1"
[31] => string(1) "1"
[32] => string(1) "1"
[33] => string(1) "1"
[34] => string(1) "1"
[22] => string(1) "1"
[23] => string(1) "1"
[24] => string(1) "1"
[26] => string(1) "1"
}
["style_id"] => string(2) "30"
["_xfToken"] => string(53) "1,1335032683,3ddd2ffb7f61cb96cd871478e76b2317d57f346b"
["_xfRequestUri"] => string(52) "/admin.php?styles/nostalji.30/template-modifications"
["_xfNoRedirect"] => string(1) "1"
["_xfResponseType"] => string(4) "json"
}
}
 
You need to insert
Code:
<xen:contentcheck>
   something
</xen:contentcheck>
inside
Code:
<xen:if hascontent="true">
      ....
<xen:else />
 
You need to insert
Code:
<xen:contentcheck>
  something
</xen:contentcheck>
inside
Code:
<xen:if hascontent="true">
      ....
<xen:else />

This happened with Add Staff Online into Members Online modification which I belive is part in the Modification Package....
 
'This also improves performance compare to template hooks and is more flexible than template hooks.'

^^^How does this improve the performance?
 
Top Bottom