Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1699334-menu_position_php_plugin.patch | 5.1 KB | eugene.ilyin |
#2 | menu_position_php_plugin.diff | 5.05 KB | skylord |
Comments
Comment #1
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedthis 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
Comment #2
skylord CreditAttribution: skylord commentedHere 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).
Comment #3
capellic@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.
Comment #4
eugene.ilyin CreditAttribution: eugene.ilyin commentedLittle notice:
I get error in line:
$apply_rule = eval(trim($php));
I think it's because
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.
Comment #5
JohnAlbinFeel free to create a separate project for this plugin. I won't add a dangerous PHP-in-the-database feature in this module. Sorry!
Comment #6
eugene.ilyin CreditAttribution: eugene.ilyin commentedOk, I created new separate module menu position php, please add link to this module on main page of module menu_position
Comment #7
eugene.ilyin CreditAttribution: eugene.ilyin commentedAny news? )
Comment #8
eugene.ilyin CreditAttribution: eugene.ilyin commentedHello. Can you add link to my module on page of module menu position?