Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
589e9f23
Commit
589e9f23
authored
18 years ago
by
Neil Drumm
Browse files
Options
Downloads
Patches
Plain Diff
#65706
by Eaton, look for page templates based upon the path.
parent
1a88d134
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.txt
+3
-0
3 additions, 0 deletions
CHANGELOG.txt
themes/engines/phptemplate/phptemplate.engine
+38
-14
38 additions, 14 deletions
themes/engines/phptemplate/phptemplate.engine
with
41 additions
and
14 deletions
CHANGELOG.txt
+
3
−
0
View file @
589e9f23
...
@@ -29,6 +29,9 @@ Drupal x.x.x, xxxx-xx-xx (development version)
...
@@ -29,6 +29,9 @@ Drupal x.x.x, xxxx-xx-xx (development version)
* 'blogapi new' and 'blogapi edit' nodeapi operations.
* 'blogapi new' and 'blogapi edit' nodeapi operations.
- user module:
- user module:
* added hook_profile_alter().
* added hook_profile_alter().
- PHP Template engine:
* add the ability to look for a series of suggested templates.
* look for page templates based upon the path.
Drupal 4.7.0, 2006-05-01
Drupal 4.7.0, 2006-05-01
------------------------
------------------------
...
...
This diff is collapsed.
Click to expand it.
themes/engines/phptemplate/phptemplate.engine
+
38
−
14
View file @
589e9f23
...
@@ -46,12 +46,13 @@ function phptemplate_regions() {
...
@@ -46,12 +46,13 @@ function phptemplate_regions() {
* The name of the theme function being executed.
* The name of the theme function being executed.
* @param $variables
* @param $variables
* A sequential array of variables passed to the theme function.
* A sequential array of variables passed to the theme function.
* @param $file
* @param $suggestions
* A suggested template file to use. If the file is not found, the default $hook.tpl.php will be used.
* An array of suggested template files to use. If none of the files are found, the
* default $hook.tpl.php will be used.
* @return
* @return
* The HTML generated by the template system.
* The HTML generated by the template system.
*/
*/
function
_phptemplate_callback
(
$hook
,
$variables
=
array
(),
$
file
=
NULL
)
{
function
_phptemplate_callback
(
$hook
,
$variables
=
array
(),
$
suggestions
=
array
()
)
{
global
$theme_engine
;
global
$theme_engine
;
$variables
=
array_merge
(
$variables
,
_phptemplate_default_variables
(
$hook
,
$variables
));
$variables
=
array_merge
(
$variables
,
_phptemplate_default_variables
(
$hook
,
$variables
));
...
@@ -62,17 +63,21 @@ function _phptemplate_callback($hook, $variables = array(), $file = NULL) {
...
@@ -62,17 +63,21 @@ function _phptemplate_callback($hook, $variables = array(), $file = NULL) {
$variables
=
array_merge
(
$variables
,
call_user_func
(
$variables_function
,
$hook
,
$variables
));
$variables
=
array_merge
(
$variables
,
call_user_func
(
$variables_function
,
$hook
,
$variables
));
}
}
if
(
is_array
(
$variables
[
'template_files'
]))
{
$suggestions
=
array_merge
(
$suggestions
,
$variables
[
'template_files'
]);
}
if
(
isset
(
$variables
[
'template_file'
]))
{
if
(
isset
(
$variables
[
'template_file'
]))
{
$
file
=
$variables
[
'template_file'
];
$
suggestions
[]
=
$variables
[
'template_file'
];
}
}
$hook_function
=
'_'
.
$theme_engine
.
'_'
.
$hook
;
$hook_function
=
'_'
.
$theme_engine
.
'_'
.
$hook
;
$default_function
=
'_'
.
$theme_engine
.
'_default'
;
$default_function
=
'_'
.
$theme_engine
.
'_default'
;
if
(
function_exists
(
$hook_function
))
{
if
(
function_exists
(
$hook_function
))
{
return
call_user_func
(
$hook_function
,
$variables
,
$
file
);
return
call_user_func
(
$hook_function
,
$variables
,
$
suggestions
);
}
}
elseif
(
function_exists
(
$default_function
))
{
elseif
(
function_exists
(
$default_function
))
{
return
call_user_func
(
$default_function
,
$hook
,
$variables
,
$
file
);
return
call_user_func
(
$default_function
,
$hook
,
$variables
,
$
suggestions
);
}
}
}
}
...
@@ -214,7 +219,20 @@ function phptemplate_page($content) {
...
@@ -214,7 +219,20 @@ function phptemplate_page($content) {
$variables
[
'node'
]
=
node_load
(
arg
(
1
));
$variables
[
'node'
]
=
node_load
(
arg
(
1
));
}
}
return
_phptemplate_callback
(
'page'
,
$variables
);
$i
=
0
;
$suggestion
=
'page'
;
$suggestions
=
array
(
$suggestion
);
while
(
$arg
=
arg
(
$i
++
))
{
$suggestions
[]
=
$suggestion
.
'-'
.
$arg
;
if
(
!
is_numeric
(
$arg
))
{
$suggestion
.
=
'-'
.
$arg
;
}
}
if
(
drupal_is_front_page
())
{
$suggestions
[]
=
'page-front'
;
}
return
_phptemplate_callback
(
'page'
,
$variables
,
$suggestions
);
}
}
/*
/*
...
@@ -256,7 +274,7 @@ function phptemplate_node($node, $teaser = 0, $page = 0) {
...
@@ -256,7 +274,7 @@ function phptemplate_node($node, $teaser = 0, $page = 0) {
$variables
[
'picture'
]
=
''
;
$variables
[
'picture'
]
=
''
;
}
}
return
_phptemplate_callback
(
'node'
,
$variables
,
'node-'
.
$node
->
type
);
return
_phptemplate_callback
(
'node'
,
$variables
,
array
(
'node-'
.
$node
->
type
)
)
;
}
}
/**
/**
...
@@ -311,16 +329,22 @@ function phptemplate_box($title, $content, $region = 'main') {
...
@@ -311,16 +329,22 @@ function phptemplate_box($title, $content, $region = 'main') {
* The name of the theme function being executed.
* The name of the theme function being executed.
* @param $variables
* @param $variables
* A sequential array of variables passed to the theme function.
* A sequential array of variables passed to the theme function.
* @param $
file
* @param $
suggestions
* A suggested template file to use.
* A
n array of
suggested template file
s
to use.
*/
*/
function
_phptemplate_default
(
$hook
,
$variables
,
$
file
=
NULL
,
$extension
=
'.tpl.php'
)
{
function
_phptemplate_default
(
$hook
,
$variables
,
$
suggestions
=
array
()
,
$extension
=
'.tpl.php'
)
{
global
$theme_engine
;
global
$theme_engine
;
if
(
!
empty
(
$file
)
&&
file_exists
(
path_to_theme
()
.
"/
$file$extension
"
))
{
// Loop through any suggestions in FIFO order.
$file
=
path_to_theme
()
.
"/
$file$extension
"
;
$suggestions
=
array_reverse
(
$suggestions
);
foreach
(
$suggestions
as
$suggestion
)
{
if
(
!
empty
(
$suggestion
)
&&
file_exists
(
path_to_theme
()
.
'/'
.
$suggestion
.
$extension
))
{
$file
=
path_to_theme
()
.
'/'
.
$suggestion
.
$extension
;
break
;
}
}
}
else
{
if
(
!
isset
(
$file
))
{
if
(
file_exists
(
path_to_theme
()
.
"/
$hook$extension
"
))
{
if
(
file_exists
(
path_to_theme
()
.
"/
$hook$extension
"
))
{
$file
=
path_to_theme
()
.
"/
$hook$extension
"
;
$file
=
path_to_theme
()
.
"/
$hook$extension
"
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment