Catégories:
Bonjour,
je voudrais savoir s’il existe un module (ou un code php) qui me permette d’afficher dans un bloc, un texte en fonction de l’url de la page, et qui prenne en compte le joker (un peu comme les droits d’accès des bloc). Le nombre de messages différents ne serait pas très important (un dizaine tout au plus).
merci pour votre aide.
- Vous devez vous identifier ou créer un compte pour écrire des commentaires

C’est pas super élégant, mais pourquoi ne pas afficher un bloc par texte, en utilisant la fonction «afficher uniquement sur les pages XXX» pour chaque bloc ?
Vincent
Formations Drupal pour WEBMASTERS, DESIGNERS et DÉVELOPPEURS.
drupalfrance
1772
C’est plus élégant :
<?php$helps = array( 0 => array ('url' => "<em>",
'text' => t("Ici c'est l'accueil")), 1 => array ('url' => "blog/</em>",
'text' => t("Mon blog")), 2 => array ('url' => "annuaire/<em>",
'text' => t("Annuaire")), 3 => array ('url' => "node/</em>",
'text' => t("Ici c'est le contenu")), 4 => array ('url' => "admin/<em>",
'text' => t("Espace administration")),
);
foreach (
$helps as $help){$path = drupal_get_path_alias($_GET['q']);
$regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\*/', '/(^||)\\<front\\>($||)/'), array('|', '.</em>', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($help['url'], '/')) .')$/';
// Compare with the internal and path alias (if any).
$page_match = preg_match($regexp, $path);
if ($path != $_GET['q']) {
$page_match = $page_match || preg_match($regexp, $_GET['q']);
}
if ($page_match == TRUE) {$message = $help['text'];}
}
print $message;
?>
vetofish
6