Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL-CMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ryan Klusman
UNL-CMS
Commits
91977061
Commit
91977061
authored
12 years ago
by
Eric Rasmussen
Browse files
Options
Downloads
Patches
Plain Diff
[gh-481] Add unl-404 menu path that fetches 404 page from default site.
Set site_404 variable to that path in unl module update.
parent
419dfe18
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sites/all/modules/unl/unl.install
+9
-0
9 additions, 0 deletions
sites/all/modules/unl/unl.install
sites/all/modules/unl/unl.module
+44
-2
44 additions, 2 deletions
sites/all/modules/unl/unl.module
with
53 additions
and
2 deletions
sites/all/modules/unl/unl.install
+
9
−
0
View file @
91977061
...
@@ -40,3 +40,12 @@ function unl_update_7112() {
...
@@ -40,3 +40,12 @@ function unl_update_7112() {
);
);
variable_set
(
'unl_module_whitelist'
,
$modules
);
variable_set
(
'unl_module_whitelist'
,
$modules
);
}
}
/**
* If site does not have custom 404 set, set it to the central UNL page.
*/
function
unl_update_7113
()
{
if
(
!
variable_get
(
'site_404'
))
{
variable_set
(
'site_404'
,
'unl-404'
);
}
}
This diff is collapsed.
Click to expand it.
sites/all/modules/unl/unl.module
+
44
−
2
View file @
91977061
...
@@ -255,6 +255,17 @@ function unl_permission() {
...
@@ -255,6 +255,17 @@ function unl_permission() {
);
);
}
}
/**
* Implements hook_preprocess_node().
*/
function
unl_preprocess_node
(
&
$vars
)
{
// Full page representation wanted for 404 page
$status
=
drupal_get_http_header
(
'status'
);
if
(
$status
==
'404 Not Found'
)
{
$vars
[
'page'
]
=
TRUE
;
}
}
/**
/**
* Implements hook_preprocess_page().
* Implements hook_preprocess_page().
*/
*/
...
@@ -278,11 +289,19 @@ function unl_preprocess_page(&$vars) {
...
@@ -278,11 +289,19 @@ function unl_preprocess_page(&$vars) {
}
}
/**
/**
* Implement
ation of
hook_menu().
* Implement
s
hook_menu().
*/
*/
function
unl_menu
()
{
function
unl_menu
()
{
$items
=
array
();
$items
=
array
();
// 404 page pulled from default site.
$items
[
'unl-404'
]
=
array
(
'title'
=>
'Page not found'
,
'access callback'
=>
TRUE
,
'page callback'
=>
'unl_404_page'
,
'type'
=>
MENU_CALLBACK
,
);
// Output html snippets for regions.
// Output html snippets for regions.
$items
[
'sharedcode/%'
]
=
array
(
$items
[
'sharedcode/%'
]
=
array
(
'title'
=>
'sharedcode files'
,
'title'
=>
'sharedcode files'
,
...
@@ -377,7 +396,7 @@ function unl_menu() {
...
@@ -377,7 +396,7 @@ function unl_menu() {
}
}
/**
/**
* Implement
ation of
hook_menu_alter().
* Implement
s
hook_menu_alter().
*/
*/
function
unl_menu_alter
(
&
$items
)
{
function
unl_menu_alter
(
&
$items
)
{
// This duplicates the form at admin/appearance/settings/unl_wdn for roles that can't 'administer themes' but have 'unl theme settings' permission.
// This duplicates the form at admin/appearance/settings/unl_wdn for roles that can't 'administer themes' but have 'unl theme settings' permission.
...
@@ -405,6 +424,29 @@ function unl_menu_alter(&$items) {
...
@@ -405,6 +424,29 @@ function unl_menu_alter(&$items) {
$items
[
'admin/modules/uninstall'
][
'access callback'
]
=
'unl_user_is_administrator'
;
$items
[
'admin/modules/uninstall'
][
'access callback'
]
=
'unl_user_is_administrator'
;
}
}
/**
* Custom page callback.
*/
function
unl_404_page
()
{
$database
=
$GLOBALS
[
'databases'
][
'default'
][
'default'
];
$database
[
'prefix'
]
=
unl_get_shared_db_prefix
();
Database
::
addConnectionInfo
(
'default_site'
,
'default'
,
$database
);
// Switch database connection to default site.
db_set_active
(
'default_site'
);
$default_404
=
unl_shared_variable_get
(
'site_404'
);
// @TODO: $default_404 should look like "node/182" but is there a safer way to retrieve nid?
$node
=
node_load
(
substr
(
$default_404
,
5
));
drupal_set_title
(
$node
->
title
);
$build
=
node_view
(
$node
,
'full'
);
$build
[
'links'
][
'#access'
]
=
FALSE
;
$build
[
'#contextual_links'
]
=
NULL
;
// Restore database connection.
db_set_active
();
return
drupal_render
(
$build
);
}
/**
/**
* Custom function that creates html snippet output at sharedcode/% paths to
* Custom function that creates html snippet output at sharedcode/% paths to
* mimic files that once existed on static UNL templated sites.
* mimic files that once existed on static UNL templated sites.
...
...
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