Hi, I'm using Flag Page with Rules to record user search history as can be seen in the demo here: Browsing History Demo.
Whilst I was able to get it to work using custom PHP in a rules action it would be great if the flag action was properly supported. I have made some changes (patch to follow) that support the use of the 'page' type argument. This allows the rules flag action to pass in the url and title which are then used by flag page instead of $_REQUEST['destination'] and $_REQUEST['title']. This also means that page flags can be set programatically without having to set $_REQUEST properties.
One problem however is that the rules data type of 'page' referenced in rules_get_event_arguments_definition() doesn't appear to be defined anywhere. I couldn't find it in any contrib module. Therefore I have added it to Rules Pages. It seems like the right place for it but let me know if it is defined elsewhere and I just missed it...
As an example, in the Rules Pages module, the following code invokes a rule event that loads a page object which can be used by the flag page action.
rules_invoke_event('search_page_view', (object) array('url' => $_GET['q'], 'title' => $title));
To set the flag programatically you would do something like this:
$page = (object) array('url' => $_GET['q'], 'title' => $title);
$flag = flag_get_flag('my_page_flag');
$content_id = $flag->get_content_id($page);
$flag->flag('flag', $content_id);
Patch to follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | rules_integration-1155136-1.patch | 3.1 KB | chaps2 |
Comments
Comment #1
chaps2 commented