summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnAlbin2007-12-17 01:20:56 +0000
committerJohnAlbin2007-12-17 01:20:56 +0000
commit608fe8f0313f959d7676c437c70954d3d018c142 (patch)
treeebde643b1620449b9ce00c17ac5d44fe491246f7
parenta8a1366d62e7392a806e96fde8d9f69c4877d0e6 (diff)
#196181: _phptemplate_callback doesn't look in sub-theme folder for .tpl.php files
-rw-r--r--CHANGELOG.txt1
-rw-r--r--template-subtheme.php50
-rw-r--r--template.php20
3 files changed, 46 insertions, 25 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 918f78d..42c7a30 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,5 @@
Zen 5.x-1.x-dev
+ #196181: _phptemplate_callback doesn't look in sub-theme folder for .tpl.php files
* Added SUBTHEME directory as a starter sub-theme for developers
#199036 by joachim: Make padding on #squeeze conditional
#199578: Fatal error on Zen Classic theme settings when using admin theme
diff --git a/template-subtheme.php b/template-subtheme.php
index ef4eaa6..c5f225b 100644
--- a/template-subtheme.php
+++ b/template-subtheme.php
@@ -53,31 +53,6 @@ function path_to_subtheme() {
return $theme_path;
}
-/*
- * These next functions allow sub-themes to have their own page.tpl.php,
- * node.tpl.php, node-type.tpl.php, etc.
- */
-function _phptemplate_node($vars, $suggestions) {
- return _zen_default('node', $vars, $suggestions);
-}
-
-function _phptemplate_comment($vars, $suggestions) {
- return _zen_default('comment', $vars, $suggestions);
-}
-
-function _phptemplate_page($vars, $suggestions) {
- return _zen_default('page', $vars, $suggestions);
-}
-
-function _phptemplate_block($vars, $suggestions) {
- return _zen_default('block', $vars, $suggestions);
-}
-
-function _phptemplate_box($vars, $suggestions) {
- return _zen_default('box', $vars, $suggestions);
-}
-
-
/**
* Allow sub-themes to have their own .tpl.php template files.
*
@@ -132,3 +107,28 @@ function _zen_default($hook, $variables, $suggestions = array(), $extension = '.
return call_user_func('_'. $theme_engine .'_render', $file, $variables);
}
}
+
+/*
+ * Rather than let _phptemplate_variables() dynamically, and slowly, define
+ * override functions for functions we will definitely need, we define them
+ * explicitly here.
+ */
+function _phptemplate_page($vars, $suggestions) {
+ return _zen_default('page', $vars, $suggestions);
+}
+
+function _phptemplate_node($vars, $suggestions) {
+ return _zen_default('node', $vars, $suggestions);
+}
+
+function _phptemplate_comment($vars, $suggestions) {
+ return _zen_default('comment', $vars, $suggestions);
+}
+
+function _phptemplate_block($vars, $suggestions) {
+ return _zen_default('block', $vars, $suggestions);
+}
+
+function _phptemplate_box($vars, $suggestions) {
+ return _zen_default('box', $vars, $suggestions);
+}
diff --git a/template.php b/template.php
index 61f2601..9be62ff 100644
--- a/template.php
+++ b/template.php
@@ -321,6 +321,26 @@ function _phptemplate_variables($hook, $vars = array()) {
break;
}
+ /* To override _phptemplate_default(), we need to dynamically define a
+ * _phptemplate_HOOK() function.
+ */
+ if (!function_exists("_phptemplate_$hook")) {
+ // Only create a function if $hook contains letters and underscores.
+ if (!preg_match('/\W/', $hook)) {
+ $declaration = <<<EOD
+ function _phptemplate_$hook(\$vars, \$suggestions = array()) {
+ return _zen_default('$hook', \$vars, \$suggestions);
+ }
+EOD;
+ eval($declaration);
+ }
+ else {
+ // Since we can't create an override function, we simply add a template
+ // suggestion that contains the sub-theme directory.
+ $vars['template_file'] = "$theme_key/$hook";
+ }
+ }
+
// The following is a deprecated function included for backwards compatibility
// with Zen 5.x-0.8 and earlier. New sub-themes should not use this function.
if (function_exists('zen_variables')) {