Jump to content

smarty + xajax librarys


Obi1-Cannabis

Recommended Posts

hi,i'm making a sistem to check avalability of hotel rooms, and i need to ressend new variables for smarty when people alter the check-in and/or check-out dates.what i was trying to accomplish this was: when you submit the new dates does dates are send into a xajax function for example xajax_changeDates($newCheckin,$newCheckout). this function will start a output buffering that will save the output of an included file that will look like the one that calls the main smarty template but will only call the inner smaller template to substitute inside a div.the code of the php that calls the main template is something like:

<?phpinclude($_SERVER['DOCUMENT_ROOT']."/../app.php");require_once($CFG->wwwroot."/lib/hotels.inc.php");require_once($CFG->wwwroot."/inc/xajax/xajax_core/xajax.inc.php");   $_SESSION["search"]["datein"] = $_REQUEST["checkin"];   $_SESSION["search"]["dateout"] = $_REQUEST["checkout"];   $_SESSION["search"]["id"] = $_REQUEST["id"];   $hotel = &new hotels();   $hotel->id =  $_SESSION["search"]["id"];   $hotel->initDat = $_SESSION["search"]["datein"];   $hotel->endDate = $_SESSION["search"]["dateout"];   $allotments = $hotel->checkAllots();//returns the number of rooms available   //Smarty Config	 $smarty = new Smarty;	 $smarty->compile_check = true;	 $smarty->debugging = false;	 $smarty->template_dir = $CFG->smartydirs . "/templates/m4travel";	 $smarty->compile_dir = $CFG->smartydirs . "/templates_c/m4travel/";	 $smarty->config_dir = $CFG->smartydirs . "/configs";   //CFG Vars	 $smarty->assign("wwwroot", $CFG->wwwroot);	 $smarty->assign("wwwinc", $CFG->wwwinc);	 $smarty->assign("wwwimagens", $CFG->wwwimagens);	 $smarty->assign("wwwsubroot", $CFG->wwwtravelroot);	 $smarty->assign("wwwsubinc", $CFG->wwwtravelinc);	 $smarty->assign("wwwsubimagens", $CFG->wwwtravelimagens);   //Data	 $datain = reversed_date($_SESSION["search"]["datein"]);	 $dataout = reversed_date($_SESSION["search"]["dateout"]);	 /****OTHER DATA****/   //Vars	 $smarty->assign("pedatain", $_SESSION["pesquisas"]["datain"]);	 $smarty->assign("pedataout", $_SESSION["pesquisas"]["dataout"]);				 $smarty->assign("available", $allotments);	 /****OTHER VARS****/      //XAJAX	 $xajax = new xajax();	 $xajax->registerFunction("changeDates");      function changerDates($newCheckin,$newCheckout) {	  GLOBAL $CFG;	  $objResponse = new xajaxResponse();	  $_SESSION["search"]["datein"] = $newCheckin;	  $_SESSION["search"]["dateout"] = $newCheckout;	  ob_start();	  include($CFG->wwwroot."/hotels/verifyNewDates.php");	  $res = ob_get_contents();	  ob_end_clean();	  $objResponse->assign("tab0","innerHTML",$res);	  return $objResponse;   }   $xajax->processRequest();   $smarty->assign('xajax_script',$xajax->getJavascript('../../inc/xajax'));	    $smarty->display("alojamentos/alojamento.tpl");?>

the verifyNewDates.php is very similar except for it doesn't have the $_REQUESTs and instead of $smarty->display("alojamentos/alojamento.tpl"); it will be$smarty->display("alojamentos/available.tpl");and in the main smarty(alojamentos/alojamento.tpl) there's a part like this:

<div id="tab0">   {include file="/alojamentos/available.tpl"}</div>

finally, inside that available.tpl is the form that changes the dates and calls the xajax function.though the xajax isn't giving the response back. can anyone help me finding out what's worng in here? or if you think this isn't the best solution for what i'am trying to do, please tell me how should i do it.Thanks in advance for any help.Big Up!

Link to comment
Share on other sites

ok i found out why the renponse wasn't comming, after hours and hours of changing code, reading manuals and post on forums. i came to find by myselft that i'am using special characters and i forgot to use $objResponse = new xajaxResponse("ISO-8859-1"); :) though there is another problem the $_SESSION vars aren't passing to the included file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...