hi,

would be nice if the current path could be ckecked if it is equal to a string. i need to call actions if a user is an a specific page. or should it be done by php?

regards

Comments

fago’s picture

Title: Condition check path » run rules for a certain path
Component: Rules Core » Rules Engine

You can already do that with a token, however it would be faster if we would do that with plain php before invoking rules. I can of adding way to add custom events for something like that - so things stay as fast as possible.

mitchell’s picture

Category: feature » support
Status: Active » Fixed

There is also a "Path has alias(es)" condition.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gagarine’s picture

Version: 6.x-1.0-beta3 » 6.x-1.1
Status: Closed (fixed) » Active

Hello,

Can we have more infos please :). I would like run a ruleset when user visite a path like "firemyrules/arg1/arg2/arg3". When you say "plain php" you think about a module? I can create a tiny costume module but how you run rulesset with PHP?

Thanks for your help

fago’s picture

Status: Active » Closed (fixed)

enable the module to get a php input evaluator + php condition + action.

gagarine’s picture

Status: Closed (fixed) » Active

The problem is not the condition but how invoke the rules. I think one way is to create a new event on a module http://drupal.org/node/298549

gagarine’s picture

Here my costum code. Hop this can help somebody.

/**
 * @file
 * Create a new event for rules when visiting a special url
 */


/**
 * Valid permissions for this module
 * @return array An array of valid permissions for the onthisdate module
 */
function expiration_date_increase_perm() {
    return array('increase expiration date of own node');
} // function expiration_date_increase_perm()

/**
 * Implementation of hook_menu().
 */
function expiration_date_increase_menu() {
    $menu['node/%/deadline-renew'] = array(
        'title'            => 'Deadline increased',
        'description'      => 'increase node expiration',
        'page callback'    => 'expiration_date_increase_fire_event',
        'access arguments' => array('increase expiration date of own node'),
        'page arguments'   => array(1),
        'type'             => MENU_CALLBACK,
    );
    return $menu;
}

function expiration_date_increase_fire_event($nid) {
    rules_invoke_event('url_expiration_date_increase', node_load($nid));
    return  t('Deadline as been increased');
}


function expiration_date_increase_rules_event_info() {
    $items = array(
        'url_expiration_date_increase' => array(
        'label' => t('After visiting node/%/deadline-renew'),
        'module' => 'ExpirationDate',
        'arguments' => rules_events_node_arguments(t('updated content'), t("content's author"), TRUE),
        ),
    );
    // Specify that on presave the node is saved anyway.
    $items['node_presave']['arguments']['node']['saved'] = TRUE;
    return $items;
}

mitchell’s picture

Status: Active » Fixed

You could use the 'user is going to view a page' event with a 'path has alias' condition.

See also #442432: Improve textual conditions (starts with, ends with, contains, is equal to, regex).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.