Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
Process chain rule in loop
Process chain rule in loop
Hi Stephen,
I've been trying several possibilities to change the template at any given time using URL "landing=x" variable but it seems that the rule chain either stops on one template and do not detect the next variable or only stay until I browse to the next menu item.
I tried with several possibilities using session variable, permanent variable, utilizing a specific variable for one template (let's say detect variable A for template A and detect variable B for template B). Also I tried setting all the template on variable A and puting in the chain a rule that removes that "variable A" before and after in the chain, put still it doesn't work.
I think I would need a loop in the rules using PHP coding. If it is possible to use the same "variable A" for all the rule that would be easier I think. I would just need to remove it whenever the URL contains the expression "landing=".
Thanks for you help. You can still login to http://www.guitarweb3.com/ to see what I did, it's pretty self explanatory.
Alex
02-Feb-11 11:51:20
Re: Process chain rule in loop
Hi atherrien,
I'm a bit puzzled about what you are actually trying to achieve. Can you spell out the scenario a bit clearer?
Don't forget that at the end of any rule you can trigger the succeed (or fail) action but still continue to the next rule. Perhaps that might help?
The standard way to use a landing variable and to make it stick for the rest of the session is this:
1st rule: detect session variable A. In succeed action: set template and stop processing
2nd rule: detect "landing=x" in the URL. In succeed action: set template, and set session variable A.
In this way, if the person goes to a "landing=x" page then it sets the session variable. On the next page the session variable will be detected in rule 1, and the template will be set (and this will continue for the rest of the session).
If you want to give people the ability to cancel the new template using a URL with "landing=y", then you could do the following:
1st rule: detect "landing=y". In succeed action: reset session variable A and stop processing. Then the person just gets the normal default template. IN fail action, continue to next rule.
2nd rule: detect session variable A. In succeed action: set template and stop processing. In fail action, continue to next rule.
3rd rule: detect "landing=x" in the URL. In succeed action: set template, and set session variable A.
I don't know if that helps... but I hope so.
Cheers,
Stephen
Re: Process chain rule in loop
Ok I will try to explain the scenario a clear as possible:
I got 5 templates and I want them to switch with an individual URL variable and stay until another URL variable is detected. Each template would have it's own URL variable expression (variable x set template x, variable y set template y).
I am still trying to make your rules work for me:
USER wrote:
1st rule: detect session variable A. In succeed action: set template and stop processing
2nd rule: detect "landing=x" in the URL. In succeed action: set template, and set session variable A.
But it doesn't work. Do I have to stop processing when the rule fails?
Re: Process chain rule in loop
Ok, I logged in to your site and got it working. It took a little experimentation to get it right, and the new "debug" mode made it a lot easier too. Did you know about that? You can turn it on from the "Parameters" button on the MetaTemplate rules page. Then, each page that you view has a panel on it that lists each of the steps that MetaTemplate goes through. This helped to remind me that when you set a new session variable you have to cancel any old ones as well, or else they trigger some of the other rules...
Anyway, here's final order of the steps, and their actions. It's a bit different to what I said before (sorry).
Step 1: "Detect Landing=1 set Metal Template + set variable A"
In the SUCCEED action, you have to do 2 things with the session variables. In the first dropdown, "delete session variables A-D" and in the second "set session variable A".
In the SUCCEED action, set the appropriate template, and "stop processing".
In the FAIL action, "continue to next rule".
Step 2: "Detect Landing=2 set Femme Template + set variable B"
Do the same as in the 1st rule, including deleting the session variables A-D. Then set variable A and stop processing.
In the FAIL action, "continue to next rule".
Step 3: "Detect Variable A and set Metal Template"
In the SUCCEED action, set the appropriate template, and "stop processing".
In the FAIL action, "continue to next rule".
Step 4: "Detect Variable B and set Femme Template"
In the SUCCEED action, set the appropriate template, and "stop processing".
In the FAIL action, "continue to next rule".
I hope that all makes sense now. Please let me know if you need any clarification.
One of the important things was to detect the "landing=x" in the URL before relying on the session variables, otherwise you couldn't change to a different "landing=..." value. So all the "landing=..." rules go first.
Best regards,
Stephen
Re: Process chain rule in loop
One last thing... sorry about that:
I have 5 templates thus in need of 5 variables. Could you provide me the mod info so I could edit one of your code file and add "Variable E" in the rule menu?
Or maybe there's a simpler alternative?
Thanks
Re: Process chain rule in loop
aaaargh... I always knew that 4 wasn't going to be enough!
Let me think about that for a bit. I need to decide whether to:
- simply increase the number of variables in all places
- or allow the user to create their own variable in a text box (and if so, how many? and would have to give option to delete an arbitrary variable as well...)
- or just provide you some code to put in the various PHP boxes.
I'll get back to you soon. For now I'll probably just provide you some code for the PHP boxes.
Cheers,
Stephen
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5941
- Posts this week:
- 1
- User Info:
- Total Users:
- 7618
- Newest User:
- goure1dhowen
- Members Online:
- 0
- Guests Online:
- 151
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked