-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for prependTemplateDir()
or more options with addTemplateDir()
- weight, duplicate handling
#1022
Comments
Could you elaborate on that second request? I'm afraid I don't understand what you mean. |
And as for your first request, would you need something like this? public function prependTemplateDir($new_template_dir, $is_config = false): void {
$current_template_dirs = $this->getTemplateDir(null, $is_config);
array_unshift($current_template_dirs, $new_template_dir);
$this->setTemplateDir($current_template_dirs, $is_config);
} |
@wisskid Yeah, that's the basic idea. Part of the reason for filing this is... that we recently found that's non-performant to repeatedly combine For a small number of paths, that's fine. But it turns out - whenever one extension adds a path, it (re)normalizes With a handful of extensions, no one notices. But for folks with a large number of extensions, it balloons. So |
thanks for the quick reply - I was writing a response but seems Tim did first so I'll go with 'what he said' on the second. On the first, I might be wrong on the second request but it's my understanding that if I have 2 bits of code that don't know about each other & each do
Then the template will potentially be added and / or processed through |
I see. In that case, we can change it as follows: public function prependTemplateDir($new_template_dir, $is_config = false): void {
$current_template_dirs = $is_config ? $this->config_dir : $this->template_dir;
array_unshift($current_template_dirs, $new_template_dir);
$this->setTemplateDir($current_template_dirs, $is_config);
} That would postpone the expensive call to _normalizeTemplateConfig up until the first load of a template. Correct? |
Yes that seems correct to me |
addTemplateDir()
- weight, duplicate handlingprependTemplateDir()
or more options with addTemplateDir()
- weight, duplicate handling
I'll try to squeeze it in asap |
thank you - you have been incredibly responsive! |
@eileenmcnaughton you're welcome! |
We have a code base (CiviCRM) that uses Smarty & can be extended by extensions.
Our main code base registers the template directory but the plugins can also register their own. However, in many cases the plugins want their directories to take precedence.
This is a feature request to be able to call
addTemplateDir()
with a weight or similar orprependTemplateDir()
.A secondary request is that this would handle duplicates. We have found that calling
getTemplateDirs()
is expensive if done between calls toaddTemplateDir()
and often the extensions are unaware of each other.The text was updated successfully, but these errors were encountered: