Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
post and get in themes.
Michael
Jamroom Team


Joined: 22 Apr 2008
Posts: 3423
Location: Tokyo

Posted: 02/05/09 18:30 
Im building a band booking calendar.

the control panel part is done, now im working on showing the calendar and taking bookings.

The part im debating now is how to display the calendar.
FIST THOUGHT:
put it into the themes as a function to be called:
{apBooking_showCalendar band_id=4 show=$show show_day='`$smarty.get.year`-`$smarty.get.month`-`$smarty.get.day`'}

problem: how do i get the variables from the address bar? the $smarty.get.year and the straight call to $show do not seam to work in the themes.


SECOND THOUGHT:
the alternative would be to do it like the comment.php file and take it all from the top url instead of the theme directory. this has other issues like having to wrap the calendar in the theme.

is there a way to get the GET and POST in the theme so the navigation on the calendar will be navigatable?


_________________
Michael Ussher
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
Brian
Jamroom Team


Joined: 09 Jul 2003
Posts: 37583
Location: Seattle, WA

Posted: 02/05/09 19:19 
You can access both $_GET and $_POST in smarty using the special $smarty variable:

http://smarty.net/manual/en/language.variables.smarty.php

However - the benefit of going through your form controller for display is that it gives you a chance to cleanup/sanitize any incoming $_POST or $_GET variables so you can avoid XSS vulnerabilities. If you do go the route of using the variables directly in your templates, make sure you have {if} statements around any variables used and that you explicitly check for what it is that is an allowed variable (i.e. use a white list approach).

Hope this helps!

- Brian


_________________
Make sure and check out:
* The Jamroom FAQ
* The Jamroom Documentation
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 02/05/09 19:31 
You actually can't use the the $smarty.get and $smarty.post variables in theme templates (at least last time I tried), because when the templates are run through the theme generator, it uses the _GET and _POST variables present at the time the generator is run. The only way that I know how to do it is to use a jr_theme_template function and pass the variable name in like:

{jr_theme_template template="some.tpl" my_get_var="GET:my_get_var"}

Then you can use the $my_get_var in some.tpl (check out how it's done in nova). You can also use jr_theme_page_param, but you can't assign it and use it in a smarty function like you want.


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Brian
Jamroom Team


Joined: 09 Jul 2003
Posts: 37583
Location: Seattle, WA

Posted: 02/05/09 19:34 
Thank you Kyle - you're correct - I was thinking Skin templates. The method of passing in a get variable like you have shown is new and supported in Jamroom 4 (and was done to work around the limitation in jr_theme_page_param).

Thanks!

- Brian


_________________
Make sure and check out:
* The Jamroom FAQ
* The Jamroom Documentation
Back to top
Michael
Jamroom Team


Joined: 22 Apr 2008
Posts: 3423
Location: Tokyo

Posted: 02/05/09 19:56 
Thanks very much, ill try this way.

Cheers


_________________
Michael Ussher
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
Michael
Jamroom Team


Joined: 22 Apr 2008
Posts: 3423
Location: Tokyo

Posted: 02/05/09 20:24 
Very Happy Very Happy Very Happy Very Happy Very Happy

works!

Thanks very much!

Thanks for the idea about checking the variables to whitelist them. I have that handled on the php side of things. switching to allow only valid variables through.


_________________
Michael Ussher
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 02/05/09 20:57 
It's a great work around! It took me a bit to figure out how you were doing it, but I finally found it! Very Happy


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Michael
Jamroom Team


Joined: 22 Apr 2008
Posts: 3423
Location: Tokyo

Posted: 02/05/09 21:41 
sorry i should have detailed it more.

in the standard page called booking_calendar.tpl is this:

Code
{jr_theme_template template="calendar.tpl" theme_dir="Whiteribbon" tpl_dir="theme" show="GET:show" year="GET:year" month="GET:month" day="GET:day"}


then in calendar.tpl is this code:

Code
{apBooking_showCalendar band_id=4 show=$show year=$year month=$month day=$day }


apBooking_showCalendar is the custom function created in the calendar module.


_________________
Michael Ussher
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 02/05/09 21:51 
I don't know if this would be possible, but it might be kind of cool if we could accomplish the same thing with a theme generator flag, i.e. in our theme.cfg file if we could do something like:


Code
theme_header.tpl | index.php | GET:foo
       index.tpl | index.php
theme_footer.tpl | index.php


If we could do that, then we could eliminate the need for jr_theme_template just to use GET vars. Then in the template we could just call the var via {$foo}.

Just a thought!

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Michael
Jamroom Team


Joined: 22 Apr 2008
Posts: 3423
Location: Tokyo

Posted: 02/06/09 23:51 
Hit a snag with this method.

The user can fill in all their details, but posting it back to itself and your back without the POST access again.

Im going to try the other method. Like how comment.php and forums.php go.


_________________
Michael Ussher
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 02/06/09 23:52 
you could always change the form method to "get" - it's not gonna be "pretty" but it'll work the same.


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.