[development] problem with drupal_goto
Lee Rowlands
leerowlands at rowlands-bcs.com
Wed Mar 17 21:07:00 UTC 2010
Hi
You could use the arg function with the php block visibility - or - use
the context module for a gui based approach.
<?php
$my_types = array('type1', 'type2');
return (arg(0) == 'node' && is_numeric(arg(1)) && ($node =
node_load(arg(1)) && in_array($node->type, $my_types))
?>
Lee
On Wed, 17 Mar 2010 16:25:31 +0100, Lluís Forns <enboig at gmail.com> wrote:
> I have used your solution to show blocks for some custom contents, and
> works ok for "node/19550" but fails on "node/19550/clients" or when
> there text attached after nid.
>
> Any hint?
>
>
> 2010/1/27 Dave Reid <dave at davereid.net>:
>> Your current approach is heading towards a world of hurt. Why not just
>> use
>> PHP for your block visibility?
>>
>> <?php
>> if ($node = menu_get_object()) {
>> return in_array($node->type, array('my-type1', 'my-type2'));
>> }
>> ?>
>>
>> Dave Reid
>> dave at davereid.net
>>
>>
>> On Wed, Jan 27, 2010 at 5:09 AM, Lluís <enboig at gmail.com> wrote:
>>>
>>> I have some custom nodes and I need some blocks to appear depending on
>>> node-type.
>>>
>>> My approach to solve the problem was replicate "/node/$nid" behavior
>>> to "/my-type1/$nid" in order to make blocks visible depending on
>>> node-type. If a user entered a view to "/node/$nid" he got
>>> "drupal_goto" to the right url.
>>>
>>> My problem now is that for some node-types /type/$nid works, but
>>> /node/$nid stopped working; any hint? I am completely lost right now.
>>>
>>> == hook_nodeapi ==
>>> .....
>>> case 'view':
>>> if ((arg(0)=='node')&&(arg(1)==$node->nid)) {
>>> switch ($node->type) {
>>> case 'my-type1':
>>> case 'my-type2':
>>> drupal_goto($node->type.substr($_GET['q'],4));
>>> break;
>>> .....
>>>
>>> == hook_menu ==
>>> ......
>>> foreach($node_types AS $key) {
>>> $items[$key.'/%node'] = array(
>>> 'title callback' => 'node_page_title',
>>> 'title arguments' => array(1),
>>> 'page callback' => 'node_page_view',
>>> 'page arguments' => array(1),
>>> 'access callback' => 'node_access',
>>> 'access arguments' => array('view', 1),
>>> 'file' => 'node.module',
>>> 'file path' => drupal_get_path('module', 'node'),
>>> 'type' => MENU_CALLBACK,
>>> );
>>> $items[$key.'/%node/view'] = array(
>>> 'title' => 'View',
>>> 'type' => MENU_DEFAULT_LOCAL_TASK,
>>> 'weight' => -10);
>>> ......
>>>
>>>
>>>
>>> --
>>> *Les normes hi són perquè hi pensis abans de saltar-te-les
>>> *La vida és com una taronja, què esperes a exprimir-la?
>>> *Si creus que l'educació és cara, prova la ignorància.
>>> *La vida és com una moneda, la pots gastar en el que vulguis però
>>> només una vegada.
>>> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
>>
>>
More information about the development
mailing list