Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
I don't think you can get away without using a little PHP for this, but I could be wrong. One way would be to make a node to use as 404 page, and use PHP filter. e.g:
<?php global $language; ?>
<?php if ($language->language == 'en') : ?>
<div>Can't find what you're looking for</div>
<?php elseif ($language->language == 'es') : ?>
<div>No se puede encontrar que usted está buscando</div>
<?php endif; ?>
You could also do something similar using the customerror module.
In that case you can create two (unpublished) nodes, and use the customerror module with PHP code similar to this that loads one of those nodes and displays it:
global $language;
switch ($language->language) {
case 'es':
$nid_404 = 45; // node id of the spanish 404 page
case 'en':
default:
$nid_404 = 46; // node id of the english 404 page
}
$node = node_load($nid_404);
if (!empty($node)) {
$node = (object)$node;
$node = node_build_content($node, FALSE, FALSE);
drupal_set_title($node->title);
return $node->body;
else {
return '<div>Error page not found! Please notify site admin.</div>';
}
Fist : there a little mistake, "}" is missing just before the "else".
Secondly, when I put your code I get this error (I use Drupal 7) :
Trying to get property of non-object dans eval() (ligne 13 dans /home/marylin/public_html/nicolas/modules/php/php.module(74) : eval()'d code)
Trying to get property of non-object dans eval() (ligne 14 dans /home/marylin/public_html/nicolas/modules/php/php.module(74) : eval()'d code)
Thanks if someone can help... I understand globaly the code but I don't knnow enough Drupal to do modifications...
Comments
I don't think you can get
I don't think you can get away without using a little PHP for this, but I could be wrong. One way would be to make a node to use as 404 page, and use PHP filter. e.g:
You could also do something similar using the customerror module.
That's good - thanks!
But I'm concerned my client will want to be able to edit the page but will not have access to the PHP input filter.
In that case you can create
In that case you can create two (unpublished) nodes, and use the customerror module with PHP code similar to this that loads one of those nodes and displays it:
Sounds good!
Thanks!
humm
I have tried your code but it doesn't work...
Fist : there a little mistake, "}" is missing just before the "else".
Secondly, when I put your code I get this error (I use Drupal 7) :
Thanks if someone can help... I understand globaly the code but I don't knnow enough Drupal to do modifications...
Use the i18n module, https:/
Use the i18n module, https://drupal.org/project/i18n, and follow this guide https://drupal.org/node/1216132
// Adam Evertsson
-----------------------------------------------------
www.adamevertsson.se - Blogging about Drupal...