How can I pass a URL variable to a MODx document if I'm using Friendly URLs?
For example, epcalendar.php?mo=06&yr=2014 should show June 2014 on my calendar page, but the parms are ignored and it displays the current month.
Another file, created outside of MODx and uploaded to the server, epc_test.php?mo=06&yr=2014 displays the proper month.
Thank you
[ed. note: pogopogo last edited this post 13 years, 11 months ago.]
you would do it this way:
[[~99? &mo=`06`&yr=`2014`]]
while 99 is the id of you calendar-page
on your calendar-page you would need a snippet, which includes the epcalendar.php
-
☆ A M B ☆
- 3,141 Posts
That's Revolution syntax which is not available in Evo, I think Bruno didn't notice the forum this was in. As for generating the links you'll just have to use [~67~]?mo=06&yr=2014.
You should just be able of using $_GET['mo'] and $_GET['yr'] in the (uncached!) snippet on the following page, but I'm not sure how that epcalendar works. It's been a while that I've done anything interesting in Evo, but I'm pretty sure nothing is stopping it from working like that.
You are sure the epcalendar.php is a MODX resource, right? It's a bit uncommon to have friendly urls use .php, but then again it's configurable so not impossible
Thanks for pointing that out! And you are right about the uncached snippet. The links are generated in a PHP script (Easy PHP Calendar) which I call from a MODx snippet. If I switch from the cached to the uncached snippet call, it works, i.e. when I display the calendar and click prev/next month, the proper month is displayed.
However ... I have another problem ... the link becomes unruly after going through a few months, e.g. events-test.php?q=events-test.php&q=events-test.php&q=events-test.php&yr=2014&mo=5&mo=6&yr=2014&mo=7&yr=2014&mo=8&yr=2014.
The links work, i.e. the proper month is displayed, but I'd like to simplify the links. The above url should simply be events-test.php?mo=8&yr=2014.
I believe the 'q=filename' parm comes from the RewriteRule in the .htaccess file for Friendly URLs. However, in this case it is not required because we're not going to index.php; we're going directly to the document. For some reason MODx is also tacking on the yr and mo parms instead of
replacing them. I need to strip off the q= parms, the extra ampersands and all but the last yr and mo parms. When I call this script from a non-MODx file, the calendar script generates nice simple links, e.g. events-test.php?mo=11&yr=2012.
I wonder if we can modify .htaccess to resolve this. This is the ReWriteRule in the .htaccess file:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
The first time I click 'next month' from events-test.php:
events-test.php?q=events-test.php&mo=11&yr=2012
Second time:
events-test.php?q=events-test.php&q=events-test.php&mo=11&yr=2012&mo=12&yr=2012
I think, you don't need to modify the .htaccess - file, but your script, how it generates the links and how it handles the url-parameters.