Page 1 of 1
How do I pass php variables and pages while converting site to CMSms?
Posted: Wed Oct 10, 2007 2:49 am
by rab
I'm converting a php site over to CMSms and having trouble figuring out how to pass php variables between pages, and how to redirect from one page to another in CMSms. For instance:
The old site has pages "schedule.php" and "game.php". When a user selects a game on the "schedule" page, I need to pass the variable "$game_id" while redirecting the user to the "game" page. The php code that does this is:
Code: Select all
if (isset($_GET["game_id"])) {
header("Location: game.php?game_id=".$_GET["game_id"]);
exit;
}
I'm a rookie php coder and even newer to CMSms. None of the solutions I tried from various forum posts worked, and both Users and Developers manuals and notes didn't help either. Can anyone lead me in the right direction?
Thanks!
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Wed Oct 10, 2007 2:30 pm
by Pierre M.
Hello,
warning : I'm not a PHP coder.
You need to redirect. Hasn't PHP http_redirect() instead of header() ?
Pierre M.
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Wed Oct 10, 2007 2:44 pm
by calguy1000
it'd be pretty easy to write a udt that did a javascript redirect
and you can pass variables on the URL as much as you want....
something like:
redirect($params['url']);
then call it like {redirect page='index.php?page=home&game_id=5'}
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Fri Oct 12, 2007 10:39 pm
by rab
Thanks for the suggestion, but I need to confess that the very basic php knowledge I mentioned I have is like a 5-volume encyclopedia compared to my knowledge of CMSms, which is more like a brochure! In other words, I didn't quite understand your answer. But, since the site I'm converting makes so much use of summary pages from which the user may select an item to then be taken to a details page of that selected item, I'm determined to figure this out.
So, to make sure I got it right, I do this:
1. Create a udt named "redirect" that consists of the code "redirect($params['url']);"
2. Call that udt from the Schedule page with "{redirect page='index.php?page=game&game_id=$_GET['game_id']'}
Is that right?
The 2 parts that confuse me are 1) where is it determined that the user has clicked on a game in the Schedule page (i.e. $_GET['game_id'] has been set), and 2) precisely how do I include the $_GET['game_id'] variable in the page tag?
Thanks for the help - getting this piece solved is a biggie!
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Fri Oct 12, 2007 11:46 pm
by calguy1000
it's
{redirect url='index.php?page=game&game_id=$_GET['game_id']'}
and as far as the rest goes I won't know unless I see all of the php source
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Thu Oct 25, 2007 5:39 pm
by rab
I'm stumped. I've tried your suggestion all sorts of different ways - with no luck - although I think I'm getting closer to the real problem.
The site I'm converting is really very simple, a fan club type site for my daughter's lacrosse team
mylaxteam.org. It makes use of "self links" a lot, and this is the part I can't get to work in CMSms. For instance, the GAMES page (schedule.php) shows a list of all games and, when the user clicks on a specific game in that list, it displays that game's details on a new page (showgame.php). The part I'm having trouble with is getting CMSms to figure out
when a game has been selected so it then knows to go to the game details page.
In the original site (php version), the trigger was the following code at the end of the schedule.php file:
Code: Select all
if (isset($_GET["game_id"])) {
header("Location: showgame.php?game_id=".$_GET["game_id"]);
exit;
}
As soon as a game on the list was clicked, the game_id got set and we headed on over to the game details page...except that's the part I can't get to work in the CMSms site. A lot of smarty errors, php errors, and if I ever get past the errors, I always end up on the home page. Grrr...
So, 2 questions:
1. What do I put into the content of the SCHEDULE page that is the equivalent of the above "If isset..." php code?
2. I'm not a php guru. I did this lacrosse site after a self-taught crash course in php, heavy borrowing of published code and snippets, and a lot of trial-and-error. Do I now need to take another crash course in Smarty, too, if I want to do anything beyond basic stuff in CMSms?
Thanks for your help, and sorry if my frustration is starting to show. If you would like to see the original site, you'll need a password, so let me know and I'll email you one.
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Thu Oct 25, 2007 9:13 pm
by Dr.CSS
Hang in there, I think you are over working it...
I believe you can use the news module with some custom news summary templates to do what you want...
Re: How do I pass php variables and pages while converting site to CMSms?
Posted: Tue Oct 30, 2007 5:46 pm
by rab
You know, I actually thought about that while I was playing with the News module a couple days ago. However, I think this specific process (go from a summary list of items to a detailed page of one selected item) is something I will be using a lot, not only in the site I'm working on now, but other projects in the pipeline as well. So what I think I really need to figure out is the CMSMS way to:
1. determine if a variable is set (by user clicking on an item in the summary page) - like the if (isset($_GET["game_id"])) php code
2. then go to the next (or any specific) page and take the "game_id" variable with you - like the {redirect url='index.php?page=game&game_id=$_GET['game_id']'} suggested by calguy
I think I'm missing a concept here - is it an issue of converting the php into smarty tags, or does the CMS structure require a different way of thinking? I've been stuck on this one issue for over a week now and, quite frankly, considering all the other coding expertise that seems to be needed (html, css, javascript, smarty, ...) to develop a good CMS-type site, I'm wondering if maybe I should just forget the CMS route and continue down the php/css/html route I started on a year ago.
And yet, my gut says CMS is the way to go, my research says CMSMS is the CMS package to go with, and my instincts say I'm so close, but .... grrr .... just not quite there!