Open Jimmi08 opened 6 years ago
Currently, i think the only way to override a tamplate is at theme level, another plugin can't do it. I've already needed that in my Euser plugin, but it's development is stalled preciselly because of that....
I think it should be possible...
@CaMer0n @lonalore thoughts please :)
I think that this is problem or bug in new version. Everywhere where was test
if(!defined($COPPA_FAIL)) , if (!$FORUMSTART) { ...
there should stay the same test for new template array:
If(!$FORUM_VIEWTOPIC_TEMPLATE['replies']) {
$FORUM_VIEWTOPIC_TEMPLATE['replies'] = $FORUM_VIEWTOPIC_TEMPLATE['thread'];
}
and you can override this in e_meta.php
At least in forum these tests are ignored.
@Jimmi08 Third-party plugin developers did many unconventional things in v1.x.
Tightened security, improved standards, and removal of globals in v2x now prevents this form of overriding from occurring. It was never a 'feature' as such, just a loophole which developers took advantage of. The test you mention above is not a good solution, but there might be a better one which could be implemented. (probably via e_shortcode.php)
Almost each old plugin uses this way to override or extend core templates. And themes did just styling, not manipulate with data.
How do you want to solve this:
$USER_FULL_TEMPLATE=str_replace('{USER_NAME}','{OIM_USER_NAME}',$USER_FULL_TEMPLATE);
quick, easy, simple
it replaces core shortcode with plugin shortcode before template parsing. It has nothing with shortcodes, it's about possibility to override template before is parsed by other plugin.
you can't replace core or other plugin shortcodes by plugin, you can't extend them, you can't replace core template by plugin template...
Oh, and of course there is unconventional workaround too.
@Jimmi08 I understand what you are requesting. What I'm saying is that the technique used by some third-party scripts in e_meta.php
(designed for setting meta data, not manipulating theme templates) was never documented, because it was never an intended 'feature' in v1.x. (You will not find a core plugin in v1.x using this technique).
So, what you're requesting is an enhancement, not a bug fix.
e107 v2.x has no "solution" for this feature right now afaik, but I'm open to suggestions.
@CaMer0n this is starting be really problem/limitation. No idea how to solve this.
But I remember that captcha has way how to override secure image handler.
Question is - override template or shortcode? My opinion is that template should be overriden.
Maybe something like e_template.php ? Loaded after core/plugin templates and before parsing templates?
What I noticed, those are most used templates:
$FORUMTHREADSTYLE = str_replace($forum_old, $forum_new, $FORUMTHREADSTYLE);
$FORUMREPLYSTYLE = str_replace($forum_old, $forum_new, $FORUMREPLYSTYLE);
$USER_SHORT_TEMPLATE_START = str_replace($user_old, $user_new, $USER_SHORT_TEMPLATE_START);
$USER_SHORT_TEMPLATE = str_replace($user2_old, $user2_new, $USER_SHORT_TEMPLATE);
$USER_FULL_TEMPLATE = str_replace($user3_old, $user3_new, $USER_FULL_TEMPLATE);
So maybe just some/core templates could have this functionality? With new plugin you create your own templates. But you can't do it with core templates
What I noticed as problem with addons is that there is no priority, they are loaded by aplhabetical order.
@SimSync if you have time and interest, maybe you could look at this and see if you have some ideas for this.
In wordpress, they use "hooks". You can register a function to be called on a specific "hook" in the hooked function to modify the output. e.g. Let's assume there would be a hook in the getTemplate() function, that is called after a template has been loaded, you could do the same what you did in v1: replace parts of the (or the whole) template with str_replace().
Thanks. I don't know if is waiting reaction from me or not.
You are right, but in e107 there are addons e_ for extending core functionality. ... and hooks in WP are confusing for many people too.
What is e_notify in WP terms? Hook? Or action?
I will try to explain where is problem for me, because I created this issue and I don't want to look that I don't answer or something. I just dislike if we are moving from what was typical for e107... not working e_PAGE is next example.
There are developers who can understand you ("the language of your tribe"). You can count them on fingers on one hand, maybe both. And they - like you - are working on core.
Then there are people like me and many others who are able coding and mostly copying someone else code. Who are using developer manual to get things working. I need examples, working code and other things. I don't understand what you are saying and what is needed to do and how to use it.
Only thing I know that with global variables and procedural programing I haven't problem to customize or change anything. Frankly, it's frustrating.
This is just explanation why I can't help with this and I will not mess your discussion anymore.
@Jimmi08 Sorry, just saw your post and your earlier one. Yes, I'm thinking e_template.php could be a way to make this work, and it would need to be checked when we use e107::getTemplate();
The reality is that the functionality you are requesting has not existing for many years, yet your request is only a couple of months old and now is suddenly 'urgent' for you. With so many other bugs and stability issues to correct, I hope you can understand why this has not been prioritized.
This will be something we can consider for v2.2.0
Thanks. Urgent was in meaning that I need to know what is planned for this. Answer 2.2 is enough.
@Jimmi08 Please remind me about this as soon as v2.2 is released. We can then experiment with something in the github repo with e_template.php etc.
@Moc I would close this or move milestone far far away. I was asking this and I don't need it anymore. Plugin global shortcodes are enough for me.
Adding example for better understanding:
you install non-core plugin hits, nothing happens on the frontend
you need manually change theme templates to add to them plugin shortcodes
There should be option for the plugin to work out of the box on the frontend, without changing theme templates.
In old version I would replace {NEWSAUTHOR} with {{NEWSAUTHOR}{HITS_UNIQUE} in a template string in e_header.php and not changes in theme would be needed.
The login menu uses {LM_EXTERNAL_LINKS} to display information from other plugins.
Not important now, it was just an explanation.
Funny, I just found that I use this in e_meta.php and it still works
$USER_TEMPLATE = e107::getCoreTemplate('user');
$user3_old = "{USER_LOGINNAME}";
$user3_new = "{USER_LOGINNAME} {UCLASS_BADGES}";
$user2_old = "{USER_NAME_LINK}";
$user2_new = "{USER_NAME_LINK} <br> {UCLASS_BADGES}";
$USER_FULL_TEMPLATE = str_replace($user3_old, $user3_new, $USER_FULL_TEMPLATE);
$USER_TEMPLATE['view'] = str_replace($user3_old, $user3_new, $USER_TEMPLATE['view']);
$USER_SHORT_TEMPLATE = str_replace($user2_old, $user2_new, $USER_SHORT_TEMPLATE);
$USER_TEMPLATE['list']['item'] = str_replace($user2_old, $user2_new, $USER_TEMPLATE['list']['item']);
@Jimmi08 Best use e_module.php instead.
Is this supported then? Or do we still need something new like e_template.php
. I am asking for the documentation status on this issue :)
@Moc it depends on the place, I think. It works with the user template. And now I found that I use it with e_meta with a signup template. I think it is because in those templates are still test if those variables are defined.
But I must say that just yesterday I had the opposite scenario:
Old plugins in e_meta.php replaced Global Template Constants
or
$USER_FULL_TEMPLATE = str_replace($forum_old, $forum_new, $USER_FULL_TEMPLATE);
How to do this with new version when they are filled later in forum_viewtopic.php:
but before it was written this way:
if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
so if constant was defined, that from plugin was used.Maybe I am wrong, but how override forum (or any) template from plugin, not from theme?