The menu's ability to load arguments based upon keywords in the menu is not enough for abstract modules like Views; these keywords translate directly to function names, but Views cannot be expected to create a specialized function for every variant of every argument it may provide. That is highly unwieldy.

However, it is fairly simple to add arguments.

This also adds a special argument, '%index', because Views also needs to know *which* argument it is, in case there is more than one.

This is simplest solution I could come up with; there are likely more, but this is Very Important.

Comments

merlinofchaos’s picture

StatusFileSize
new2.54 KB

Note: chx wrote the bulk of this patch, and I forgot to credit him on my initial posting. I added the %index stuff.

At his request, I also just added %map which will solve http://drupal.org/node/177488 as well, which currently has a similar patch in it but I think this one will work out better.

This reroll also includes more comments.

chx’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.54 KB

Christmas came early with %map -- it's solely merlinofchaos' invention. What a nice solution! Yes I have written some of this and I am fixing a typo in here but otherwise, it works and works well and does nto break anything existing and it's commented nicely.

chx’s picture

Title: Menu load function needs arguments » Beta 2 breaker: menu load function is not flexible enough
Assigned: Unassigned » chx
pwolanin’s picture

a quick look - seems reasonable, though I'm rather unclear on when you'd use %index

merlinofchaos’s picture

Views would use %index when it has multiple args embedded in the URL and it needs to match them up to the actual argument.

Take the simple URL of: view/%/%

My view might have the first one as a node object and the second one as a quatloo object (something clearly defined by a module extension and is nothing known to any of our installations) and views is able to direct traffic so that it gets identified properly...but if and only if it can tell one argument from the other. Since this patch only has a single 'load arguments' line, which is sufficient for 99.9% of the URLs out there, that's fine, but a little extra %index makes it work in the expanded case.

pwolanin’s picture

ah, I hadn't read the patch in enough detail, it's starting to make sense now.

I'm not sure whether to love or hate this bit:

if (is_array($function)) {
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Discussed this with chx, brainstormed some documentation fixes and committed. Unfortunately I cannot think of better then naming this $function, as most of the time this indeed will be a function name. $callback would not be of any improvement here IMHO.

Anonymous’s picture

Status: Fixed » Closed (fixed)
profix898’s picture

Is there any documentation available for this? Or any example code? I cant seem to get this implemented ...