hey there,

I'm producing a video gallery website. the main functionality is that the user can only see videos in the gallery on the home page, not individual ones.

I tried to create a simple rule for anonymous users, when accessing content of type Video, to be redirected to the home page, where the gallery is. but it didn't work.

my rule consists of the following parts:
1) event: content is going to be viewed
2) content is type: Video
3) page redirect: <front>

simple as that, but no joy. any ideas are appreciated.

thanks in advance,
Luciano

Comments

jstushnoff’s picture

I WAS doing pretty much exactly the same thing successfully up until a few days ago when I upgraded from Core 6.12 to 6.15 and from Rules 6.x-1.0 to 6.x-1.1
Now I just get a blank page (white screen) no matter what I try including disabling/clearing all cacheing.
Can anyone else get the page redirect action to work with the latest versions of core and rules?

EDIT: I have tried this with both custom and garland themes; if someone wants a list of module I have installed, let me know (it's quite long and it's on a live site so I don't want to turn any off right now for testing)
luco, if you post your list of installed modules I'll see if we have any commonalities that could be conflicting.

jstushnoff’s picture

Component: Rules Core » Rules Engine

Found the 'Debug rule evaluation' setting, I get the following message after trying to go to a page that is supposed to trigger the rule (and does, but gives me a white screen), then going to another page (a category) so I can see the message.

0 ms "Content is going to be viewed" has been invoked.
0.111 ms Executing the rule "Redirect event dates to main event description page." on rule set "Content is going to be viewed"
0.317 ms Condition "Viewed content is Event Date or Event Date - Repeating" evaluated to TRUE.
164.152 ms Action execution: "Page redirect"
164.284 ms Evaluation of "Content is going to be viewed" has been finished.
0 ms "Content is going to be viewed" has been invoked.
0.096 ms Executing the rule "Redirect event dates to main event description page." on rule set "Content is going to be viewed"
0.287 ms Condition "Viewed content is Event Date or Event Date - Repeating" evaluated to FALSE.
0.35 ms Evaluation of "Content is going to be viewed" has been finished.

I'm noticing that the rule seems to be run twice; with the condition evaluating to FALSE on the second run, any chance that has something to do with it? Any tips as to where I can look in the code (or elsewhere) to fix this? I am becoming more familiar with the Drupal api, but am not familiar with Rules' code yet.

mitchell’s picture

Status: Active » Fixed

is not a valid token or path.

Use the path that you set manually in the system settings. By default this is 'node' so that is likely what you are going to use, unless you changed it.

sethviebrock’s picture

Status: Fixed » Active

Same issue here. The rule is evaluated *twice* -- first time true, second time false. The page redirect fails to execute for anon users on the first (or second) evaluation of the rule, no matter how hard I try to force it w/ the Rules redirect options (i.e. ignore the destination param, etc). For example, try redirecting anon users from /user/password to an external URL (in our case, an aMember membership mgmt URL).

0 ms "User is going to view a page" has been invoked.
1.636 ms Executing the rule "Redirect user from /user/password to aMember" on rule set "User is going to view a page"
1.861 ms Condition "Path is /user/password" evaluated to TRUE. (**** I check this via arg(0) === 'user' && arg(1) === 'password' ***)
1.975 ms Action execution: "Show a configurable message on the site"
5.086 ms Action execution: "Page redirect"
5.215 ms Evaluation of "User is going to view a page" has been finished.
0 ms "User is going to view a page" has been invoked.
1.602 ms Executing the rule "Redirect user from /user/password to aMember" on rule set "User is going to view a page"
1.831 ms Condition "Path is /user/password" evaluated to FALSE. (**** I check this via arg(0) === 'user' && arg(1) === 'password' ***)
1.886 ms Evaluation of "User is going to view a page" has been finished.

rburgundy’s picture

subscribing

les lim’s picture

The rule isn't firing twice on the original page view. It's firing ONCE for the original page view, redirecting you to a new URL, and then firing again for each new node that it is loaded at that new URL.

An important thing to note is that the rule will be evaluated not just when viewing the full node, but on teasers as well. If the target of the redirect is a URL with teasers, those teasers might cause the rule redirect action to be successfully executed all over again. This is an infinite loop that will never resolve, which I bet is what's causing your white screens.

Try setting further conditions on the rule, such as "Check a truth value" with the value being

echo $page;

But including the open and closing php brackets, and all on one line.

fago’s picture

Category: bug » support
mitchell’s picture

Status: Active » Fixed

Closing old issues. If this issue persists, please try the latest versions and if necessary reopen the issue or create another.

Status: Fixed » Closed (fixed)

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