[development] Mapping aliases to menu items when having multiple aliases

Olivier Jacquet ojacquet at jax.be
Thu Aug 13 13:46:25 UTC 2009


Interesting approach and certainly a possibility.

I've taken another route though. My example wasn't correct to illustrate 
the issue I was having. I should've used context1/about and 
context2/about in stead of some-path and other-path. Because in the 
former case the node can actually have only one alias and it is possible 
to add the context in other ways.

At first I was writing my own module that adds a context with 
custom_url_rewrite_outbound() and strips it in hook_boot(). Then you can 
get the context by path_context_get() which you can use in the block 
visibility settings. That would completely solve my issue.

Currently I'm trying to achieve that by using the purl api but the 
documentation is somewhat sparse.





Aaron Winborn wrote, On 13/08/2009 15:29:
> You might set up a View to a full node for the context.
>
> Olivier Jacquet wrote:
>> Yes, I've seen hook_menu_link_alter() and it is only called on saving
>> a menu link and the $item variable does not contain the path alias,
>> only the system path. So you can't even use it to link the inputted
>> path alias to the mlid.
>>
>> I'm unsure what it could be used for in my case...
>>
>>
>>
>> Earnie Boyd wrote, On 13/08/2009 14:50:
>>> Quoting Olivier Jacquet <ojacquet at jax.be>:
>>>
>>>> I'm looking for a way to create a module that allows you to map which
>>>> url alias you want to associate with a specific menu entry when you
>>>> have more than one alias associated with a system path. I've
>>>> investigated this and cannot seem to find a way to implement it.
>>>>
>>>> The path module lets you create multiple url aliases for a node. The
>>>> paths some-path and other-path can both be pointed to node/1. When
>>>> someone creates a menu item and uses some-path to create it it's
>>>> converted to node/1 and it is that path that is stored in the
>>>> menu_links table.
>>>>
>>>> Then, in the case of the blocks generated by the menu module links are
>>>> rendered through theme_menu_item_link() which calls l() which uses the
>>>> first alias it finds and for the primary/secondary menu it's usualy
>>>> theme('links', array()) which also results in a call to l(). In the
>>>> former theme function you have access to the mlid but in the latter
>>>> you haven't. This means there is no sane way to accomplish the
>>>> functionality I want, I think.
>>>>
>>>> Does anyone have suggestions to accomplish this?
>>>>
>>>> The reason I want this is that I want to store context in the url
>>>> alias, eg. context1/about and context2/about which point to the same
>>>> node. This allows showing different blocks when navigating through a
>>>> specific context. Maybe there is another way to achieve this?
>>>>
>>>> Note: I'm aware of duplicate content issues etc.
>>>>
>>>
>>> Have you seen http://api.drupal.org/api/function/hook_menu_link_alter?
>>>
>>> --
>>> Earnie
>>> -- http://r-feed.com/ -- http://for-my-kids.com/
>>> -- http://www.4offer.biz/ -- http://give-me-an-offer.com/
>>>
>>>
>
>


More information about the development mailing list