I know the idea of this module is simplicity, but why not create a rules trigger for custom links? This would then allow people to create more complex logic for when to show a link, and probably reconfigure the fields. The big plus to this is that if ctools (exportables) ingeration happens then both links and the rules associates with them can be exported to features modules.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Editing rule Hide -Add Images- link for non-gallery-authors. | gallery_1264806251118.png | 40.71 KB | frankcarey |
| #1 | custom_links_rules_integration-696302.patch | 3.43 KB | frankcarey |
Comments
Comment #1
frankcarey commentedScratched my own itch :) This now makes it easy to replace nodereference_url using prepopulate (I wanted users to be able to change the gallery nodereference of an image later, but I only want the custom link to show for authors of the gallery). Much more complex logic could be put in now as well.
Additions to the form
There is a new "Use rules to limit link visibility" check box at the top of the form. To use rules you enable this on a link-by-link basis.
Changes to the database
A new field is added to the db schema called "use_rules". an update_2 is made to update the database. So, Make sure you run update.php!
Rules Integration
This implements one event, one condition, and one action.
1) Event: Custom Links being built - this event fires during _custom_links_build_links(). If $link->use_rule is true and rules is enabled, it will fire off the event, passing the link, global user, and the author user to rules, where any other conditions and actions have the chance to work.
2) Condition: The one condition that was needed besides the ones that come with rules was a check for the link_key, so that you can have this rule effect all links enabled for views or just specific ones.
3) Action: Set the Link Visibility. This takes a boolean value (specifically 0 or 1, not TRUE of FALSE) and assigns a $link->visibility to the link, which is then checked and if the visibility is set and false, then it does a "continue;" and wont show that link. Links are assumed to be visible until the visibility is set to FALSE. The other filters in the link configuration form continue to operate as before.
Comment #2
frankcarey commentedComment #3
frankcarey commentedHere is a screenshot of what the rules UI looks like.
Comment #4
KiuzHack commentedI'm very interested to your patch,I have another Patch of this module, if you would you like, I can add all your path to my updated module on gitHub
http://github.com/kiuz/custom_links
http://www.pillsofbits.com/project/custom-links-hacklinks-drupal-module
Comment #5
frankcarey commented@KuizHack - feel free to reuse this patch, but it's best to get everything approved through the central project so that it will be supported in the future.
Comment #6
nancydrufunction custom_links_update_2() is Drupal 5 format. Please use a proper db_add_field and remove the db_type stuff.
Comment #7
skizzo commentedsubscribing
Comment #8
henrijs.seso commentedThis is cool. Would be nice to have also rule trigger - custom link is clicked. Setup could be link url 'rules/%node/%user/something/something' and rules could use arguments from this to do its magic.
Comment #9
skizzo commentedI applied patch #1 to Custom Links 6.x-1.4, successfully run update.php and set "Use rules to limit link visibility" for a couple of custom links. Still, when adding a new triggered rule I do not see any "Custom Links being built" option in the Event drop down list... Is there any other setting that I am missing?
Comment #10
skizzo commentedHow about applying fix #6 so that the issue state can be reverted to "needs review"?
I have no programming skills, but would really like to see the feature
included in next release. Thank you.
Comment #11
kevin.mcnamee@mailbox.org commentedsubscribing