Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
theme system
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
7 Dec 2005 at 14:18 UTC
Updated:
22 Dec 2007 at 04:33 UTC
Instead of template.php , let's include template*.php
| Comment | File | Size | Author |
|---|---|---|---|
| template_includes.patch | 491 bytes | chx |
Comments
Comment #1
Tobias Maier commenteddo I read your patch the false way or do you include all template.*.php files?
why do you want to have this this?
Comment #2
chx commentedthat's template*.php and it's needed so that people can easily redistribute template.php chunks. Think flatforum -- there will be more IMO because of form API.
Comment #3
Tobias Maier commentedyoure right +1
but maybe to it would be nice to have a naming covention for this files:
i would like it if only the template.php and all template_*.php would be included
Comment #4
Cvbge commentedThis means you need to scan whole directory. What about performance?
I'm not template guy, so I don't understand your explanations. Could you explain more clearly how would this benefit users?
Comment #5
morbus iff+1 to this. Tobias: using underscores is a bad idea, as it breaks with phptemplate tradition; you create "node.forum.tpl.php", not "node_forum.tpl.php" to theme forums, for example.
Comment #6
Tobias Maier commentedwhats going on with this?
I think it is a good function because it allows us to implement code snippets in a fast way, so users can start to creat template*.php collections which allows them to reuse parts of them very fast
Comment #7
adrian commentedI would +1 this, as I really like the functionality .. but I don't think we should be running file_scan_directory(dirname($template->filename), 'template.*\.php')) for every page load.
It's very likely quite expensive, although I have no metrics to base this on (other than it being one of the most expensive calls on admin/modules).
Comment #8
varunvnair commentedHow about maintaining a list of template*.php files someplace (in the database or a file) and refreshing this list only when admin visits the themes configuration page. This might help improve performance.
Comment #9
varunvnair commentedHow about maintaining a list of template*.php files someplace (in the database or a file) and refreshing this list only when admin visits the themes configuration page. This might help improve performance.
Comment #10
markus_petrux commentedThe same way there's an input format that allows you to "write" code, what about another input format that allows you to "include" PHP code? If the location is known, even a drop down could easily allow you to select scripts.
...just an idea, if it's about code snippets.
Comment #11
Jaza commentedMoving to 6.x-dev queue.
I don't really think this is needed. If themers want to split up their template.php, then they can manually
include_oncetheir extra template*.php files inside template.php.Or maybe a better idea would be to have a
mythemename_include_files()function that you could put in template.php, that would return an array of template*.php files to include. Not much different to including them manually, but it would make including a bit easier, and it would encourage people to split up their template.php, simply because the hook/callback mechanism is there.Comment #12
Crell commentedRemember that include()ing lots of files creates a bigger performance hit that including one big file. It's more disk IO, and disk IO == slow. Encouraging people to split up template.php into lots of files only increases the disk IO and hurts performance. If you're doing enough code in template.php that you really do need to split it up for manageability reasons, then you should know enough about PHP and Drupal that you can do your own list of includes at the top of the file and be done with it.
Comment #13
morbus iffCrell, Jaza: you're missing the goal of this feature. Consider a module that ships with a template.modulename.php file and instructs the user to place it in their theme directory. Now, the module can ship with specific core theme overrides that make it all purdy and useful by default. Granted, without this feature, the module could still do that, but the themer would be given another instruction: to add the include_once manually to their template.php, which presumes that they even HAVE a template.php. The goal here is not to encourage the themer to split up their stuff into multilple file chunks: the goal is to make it easier for modules to ship with theme overrides that value-add its capabilities.
Comment #14
RobRoy commentedYeah, +1 on what Morbus said.
Comment #15
chx commentedmodule preprocess nicely fits the bill
Comment #16
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.