Wondering if you'd consider adding a Condition that allows us to enter PHP. I have a situation where I want a node to appear in a menu path based on the value of a field. I'd like to be able to interrogate the $node and return TRUE or FALSE.

Thank you for this module. I have tried many trail modules in the past and none have worked as well as this one.

Comments

socialnicheguru’s picture

this is a good idea.

Use case:
I have a content type, blog
I click on any on the edit tab
I would like the menu to still be triggered.
right now node/nid/edit is what comes up for the edit tab so I can't create a condition to satisfy it

skylord’s picture

Status: Active » Needs review
StatusFileSize
new5.05 KB

Here you are a small quick'n'dirty PHP condition plugin. I suggest export more variables (along with $node as now) and may be add access permission... But this simple solution works OK for me. :-)
Patch attached has to be applied to module dir (ver. 7.x-1.1).

capellic’s picture

Status: Needs review » Reviewed & tested by the community

@skylord, thank you!!!!

The patch applied cleanly, but only one problem. The two new files (menu_position.php.inc, menu_position.php.js) were added in the module's directory instead of the plugins directory, which is odd given that the patch clearly has the path. I moved the two files, cleared cache and the PHP fieldset and field appear on the rule add/edit form.

This works great. Can we get this patch applied to DEV?

To help others along, here is the code I used to evaluate a multi-value field.

foreach ($node->field_institution_type['und'] as $row) {
  if ($row['value'] == 'partner') {
    return TRUE;
  }
}
return FALSE;
eugene.ilyin’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new5.1 KB

Little notice:
I get error in line:
$apply_rule = eval(trim($php));
I think it's because

Note: Because this is a language construct and not a function, it cannot be called using variable functions.

Source - http://php.net/manual/en/function.eval.php

I wrote few fixes for this patch.

I think this patch will be very useful. Please apply it. I will be very happy if you add me and skylord as commiters of this patch.

johnalbin’s picture

Status: Needs review » Closed (won't fix)

Feel free to create a separate project for this plugin. I won't add a dangerous PHP-in-the-database feature in this module. Sorry!

eugene.ilyin’s picture

Status: Closed (won't fix) » Needs review

Ok, I created new separate module menu position php, please add link to this module on main page of module menu_position

eugene.ilyin’s picture

Any news? )

eugene.ilyin’s picture

Hello. Can you add link to my module on page of module menu position?