Created
August 19, 2010 16:47
-
-
Save benklocek/538334 to your computer and use it in GitHub Desktop.
Drupal Snips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For 403 @ /admin/settings/customerror | |
// Title: Access Denied | |
<?php global $user; // http://www.kinetasystems.com/blog/creating-custom-error-pages-in-drupal ?> | |
<?php if ($user->uid): ?> | |
<p>Sorry <?php print $user->name; ?>, you don't have permission to view the page you've just tried to access.</p> | |
<p>If you feel that you have received this message in error, please | |
<a href="/about">contact us</a> with specific details so that we may review your access to this web site.</p> | |
<p>Thanks</p> | |
<?php else: ?> | |
<p>This page may be available to clients and registered users only. Please select from one of the other options available to you below.</p> | |
<ul> | |
<li><a href="/user/login?<?php print drupal_get_destination(); ?>">Login</a> to view this page</li> | |
<!--<li>Use the <a href="search">search</a> facility</li>--> | |
<li>Go to the <a href="/">home page</a></li> | |
</ul> | |
<?php //print drupal_get_form('user_login'); ?> | |
<?php endif; ?> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Title: Requested Page Not Found | |
<p>Sorry, no content was found at the requested path - it's possible that you've requested this page in error.</p> | |
<p>Use the search form below, or go to the <a href="/">home page.</a></p> | |
<?php | |
// check that the search module exists and the user has permission to hit the form | |
if (module_exists('search') && user_access('search content')) { | |
// cool! - customerror doesn't trash the page request and the full path is available | |
$path = $_REQUEST['destination']; | |
// bin anything that's not alphanumeric and replace with spaces | |
$keys = strtolower(preg_replace('/[^a-zA-Z0-9-]+/', ' ', $path)); | |
// retrieve the search form using the data we've pull from the request | |
// note that we can override the label for the search terms field here too | |
print drupal_get_form('search_form', NULL, $keys, 'node', 'Search terms'); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //if user can administer, display edit link with return url | |
if (user_access('administer nodes')) | |
echo l( | |
t("Edit"), | |
"node/$object->nid/edit", | |
array( | |
'query' => array('destination' => $_SERVER['REQUEST_URI']) | |
) | |
); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function themename_preprocess_page(&$vars, $hook) { | |
drupal_add_feed(url('http://feedproxy.google.com/feedname'), t('Feed Title')); | |
$vars['head'] = drupal_get_html_head(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment