Extension to use TPL tags and functions in menu slots
Macik |
|
---|---|
DescriptionCotonti have a predefined custom tags that admin can use in templates. Content of these tags called «menu slots» can be altered via administration web interface. As a default, menu slots allow to use only simple html text. With this extension you can use common TPL tags and function calls like in TPL files.
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
Kingsley |
|
---|---|
Nice, will this work with every tag? of plugins and modules too? |
pieter |
|
---|---|
... can we help you ...
|
Macik |
|
---|---|
Nop. It's initializes on «global» hook (in common.php). But all main resouces, like lang strings will work. (ex: {PHP.L.Main}) All standard functions will work too ({PHP|cot_url('page', 'c=news')}).
Main usage of menu slots is to easy maintain menu or common block of code for use in templates. But last trend for it is to use cot_* functions and makin «IF» blocks right in TPL files. Slot'n'Tags - is attempt to combine better of these ways. ps: already added in downloads and being rewieved.
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
Trustmaster |
|
---|---|
That's a cool thing! Any real world use case examples? Here's another idea that i never had time to implement: so we have N slots in configuration by default. Why not make an admin tool that would add any slots you need on demand, using its own table and making them available via global tags like {PHP.out.slots.my_super_slot}. May the Source be with you!
|
Kingsley |
|
---|---|
#36376 Trustmaster: That would be a good one for some (personally I frequently use the slots). But wouldnt that in combination with making plugin tags availible too, make a it a more versetile tool? I never really liked the restrictions that many plugins have. Maybe an simple example is in order: Take the latest donations plugin for example. It only shows on the index. and when I want to display that for example in a certain list, I have to do crazy stuff to add it in there, whilst if it were possible to add it via a slots, it will be easy peasy to achieve.
Yeah, and i know that for the lot of you achieving that example is something you can do blind. But he, limited to html/css here, so yeah, I am always looking for ways to make my own life a bit easier, which with this neet little plugin already is helping (thank you Macik). I for one am keeping my fingers crossed that this can be achieved..
|
Trustmaster |
|
---|---|
@Kingsley Yeah, that's why I've been releasing a lot of plugings which work in the templates this way: {PHP|insert_me_anywhere('some_params')}. It requires some good reasoning though whether to make something global or for a fixed place only, so many plugs (especially the old ones which could not benefit from the new CoTemplate features) still work the old way. May the Source be with you!
|
Macik |
|
||||
---|---|---|---|---|---|
#36386 Trustmaster: It's a good practice and I use it too. But… It has a back (negative) side. If we use this style: «insert_me_anywhere» callbacks - we force to load bundle of code in advance, so we have pack of functions in global space that can be called never at all. For example, lets see in «attach2» plugin (it's great itself but I speaking now about callback styles only). It always load `attach2.functions.php` in «global» hook. What does it mean - 23kb file loaded and adds 26 addition functions in global space. It's not terrible themself but it happend on all pages. More plugins - more junk loaded and waste resources. And I think we have to choose solution from 2 ways:
And I preffered second one. So it should be simple to inplement, not crashed logic of use tpl callbacks, and can be done backward compatible in plugins. https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
|||||
Dit bericht is bewerkt door Macik (2012-12-02 19:55, 12 jaren ago) |
Trustmaster |
|
---|---|
Macik's right, global tags and callbacks have their side effects, that's why we don't just use them everywhere. Regarding the autoloading thing, I definitely prefer the second way. I actually consider applying blacklists and whitelists on the TPL callbacks, because currently it has no restrictions at all which is not very secure. Autoloading could be an addition to it. May the Source be with you!
|