Hello,
I'm stuck for while now by using this very convinient module (Thanks a lot to the maintainer) at the following use case:
I'm using page manager to create my pages. I have a custom page (path: node/%node/anything).
How can I place a rules link on that page?
It seems it can only be placed on a certain entity page. Or am I missing something here?
Thanks in advance!
mudds
Comments
Comment #1
mudds commentedAfter reading the Readme-file I came across the developers suggestion to use the rules_link_render_link() in an own module. As I am new to Drupal and it's module development, could anybody give me feedback, if this is the only was do achieve my posted use case?
thanks
mudds
Comment #2
blackclover commentedsubscribe
Can't figure out which arguments need to be passed Sample please. Thanks
Comment #3
mudds commentedHere's my use case:
I need to implement a voting for nodes with several constraints:
The user has overall 3 votes. He can spread them to 3 different nodes or give all his 3 votes to one node.
The user is on a certain node page (node/%node:nid).
On that page, there's a Link (not a rules link):
Title: "Vote now" for that node
Anchor: node/%node:nid/vote
On that vote page, I thought a rules link would be great to trigger the voting action and conditions.
But now I'm not sure, if the easiest way is to write my own custom module.
What do you think?
Comment #4
sepgil commentedhmm... I'm not sure too, since I've never used page manager.
Theoretically you could simply use the 'Show link in entity' feature of rules link, if there is a way to get the nid of the node you're voting for(which I guess you'll probably need). Otherwise you'll to pass the nid to the rule set and condition, which is currently only possible using either views or the rules_link_render_link() function.
If you would like to use that function just look at the documentation for the function in rules_link.module @ line 170.
The first parameter is the rules link itself, you can get that by using rules_link_get_links($link_names = NULL).
The second is the current entity id, in you case the nid of the page.
The third is the destination and the fourth the parameters you would like to pass to the rule sets and conditions.
Comment #5
blackclover commentedSorry but I'm a php noob and trying to figure this out using a custom content panel with PHP test format. Here's my code. print_r ($rules_link); works great but rules_link_render_link must not be right. Any help will be appreciated.
This generates:
Notice: Trying to get property of non-object in rules_link_get_rules_set_name() (line 101 of /home/edelib/public_html/sites/all/modules/rules_link/rules_link.module).
Notice: Trying to get property of non-object in rules_link_check_visibility() (line 313 of /home/edelib/public_html/sites/all/modules/rules_link/rules_link.module).
Notice: Trying to get property of non-object in rules_link_get_condition_set_name() (line 94 of /home/edelib/public_html/sites/all/modules/rules_link/rules_link.module).
Comment #6
blackclover commentedI did however get the links to show up in view pane panel by creating a view for the content type where the link is located. It's set up as with the format html-list, category content pane. I added the Field content:my_link_name under and added a Advanced > Content:nid contextual filter set to Provide Default Value > content id from url. This will return one row with the link in it when it's place in the panel page (the preview will be empty when you are creating it in admin)
Add this to you custom page region with Add content > content pane > my_rule_link_view_name and you should be good to go. You can apply css to the region or the view to make it look like you want.
Still want to figure out how to do it with Custom content PHP text format though (see above)
Cheers
Comment #7
mudds commentedThank you sepgil,
I cannot achieve the first way by 'showing link in entity'.
I think, I'll try to implement my first module and maybe use your rules_link_render_link() function.
thanks for your support.
mudds
Comment #8
blackclover commentedsorry about the grammar....just waking up on the west coast here
Comment #9
mudds commentedand thanks to blackclover for describing to get the rules into a view (list of nodes).
This is my up next use case, after I achieved to display a rules link within a custom page without a view in it.
cheers
Comment #10
mudds commentedand thanks to blackclover
for describing how to get rules links into a views list of content.
this is my up next use case to implement after achieving to display a rules link on a custom page without views in it.
cheers
Comment #11
blackclover commentedmudds you can use #6 to display a single rules link within a custom page. The view content pane (link) looks and behaves exactly like the link on a page not rendered using panels. The contextual filter only returns the link for the current page.
Comment #12
markiz commentedThank you for this great module!
For me works this snippet to display link in template:
print render(rules_link_render("name_of_rules_link", $node->nid, $destination = NULL, $parameters = array()));
name_of_rules_link - this string is part of url, when editing rules linkg
Comment #13
rogical commentedPanels are really important and powerful now, if we can show this link on context.
Comment #14
rogical commented// An example for make sticky in panels with rules link
$sticky = '%node:sticky'; $promote = '%node:promote';
$destination = drupal_get_destination();
if(isset($sticky) && $sticky == 'true') {
$rules_link = rules_link_load('unstick');
$output = rules_link_render_link($rules_link, '%node:nid', $destination, array());
if(!empty($output)) {print '
';}
} else {
$rules_link = rules_link_load('stick');
$output = rules_link_render_link($rules_link, '%node:nid', $destination, array()); print '
';
}
Comment #16
marco.bAnother sitebuilder possibility is to place the rules_link as a field in a views_content_pane which can be placed in your panels layout.