|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
shanto Smarty n00b
Joined: 26 Aug 2006 Posts: 3
|
Posted: Wed Aug 30, 2006 5:23 pm Post subject: smaty with xajax |
|
|
is there any way to use smarty with xajax.if possible please mention the way with a simple example |
|
Back to top |
|
gnuffmaster Smarty Elite
Joined: 13 Jul 2006 Posts: 440 Location: Düsseldorf, Germany
|
Posted: Thu Aug 31, 2006 12:52 pm Post subject: |
|
|
Sure this is possible and very simple. I use a lot xajax in smarty templates.
1st, define all the php functions you want to use and register them for xajax.
2nd put all the needed xajax stuff in your tpl:
[php:1:1c355f0295]$smarty->assign('xajax_javascript', $xajax->getJavascript());[/php:1:1c355f0295]
And in your template you can use all the js functions you defined for xajax automaticly.
Read also the examples on the xajax site. |
|
Back to top |
|
mehmet soylu Smarty n00b
Joined: 10 Jul 2007 Posts: 2
|
Posted: Tue Jul 10, 2007 11:47 pm Post subject: |
|
|
really thank you very much... |
|
Back to top |
|
monotreme Smarty Regular
Joined: 22 Feb 2004 Posts: 97 Location: USA
|
Posted: Wed Jul 11, 2007 6:16 am Post subject: I too use xajax with smarty |
|
|
all the time.
the only thing that might trip you up is the getting the generated javascript...
I do it like this:
all ajax setup stuff.....
$xajax->processRequests();
//now instead of printing it out right now, get it in a var
$inline .= "\n" . $xajax->getJavascript('classes/');
and $inline is a var where you accumulate all your inline javascript code and you pass it
to your master smarty template when u are ready to render. _________________ Your online 24/7 box office
http://www.tixrus.us |
|
Back to top |
|
Filip Smarty n00b
Joined: 09 Dec 2007 Posts: 2
|
Posted: Sun Dec 09, 2007 1:24 pm Post subject: |
|
|
I use the exact same method and it works. But the generated HTML code is incorrect. The javascript is put at the beginning of the HTML page.
Code: |
<script type="text/javascript">
var xajaxRequestUri="register.php";
var xajaxDebug=false;
var xajaxStatusMessages=false;
var xajaxWaitCursor=true;
var xajaxDefinedGet=0;
var xajaxDefinedPost=1;
var xajaxLoaded=false;
function xajax_ajax_checkUsername(){return xajax.call("ajax_checkUsername", arguments, 1);}
</script>
<script type="text/javascript" src="class_ext/xajax/xajax_js/xajax.js"></script>
<script type="text/javascript">
window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\nURL: class_ext/xajax/xajax_js/xajax.js'); } }, 6000);
</script>
<?xml version="1.0" encoding="iso-8859-1"?>
<DOCTYPE...>
<html xmlns="..." xml:lang="nl">
<head>
<title>...</title>... |
I'm trying to fix this issue, because I want to produce correct HTML But so far I haven't found anything.
I managed to put the javascript at the correct place by putting the code between {php}{/php}. But then the function doesn't work anymore.
Any ideas? |
|
Back to top |
|
Filip Smarty n00b
Joined: 09 Dec 2007 Posts: 2
|
Posted: Sun Dec 09, 2007 1:57 pm Post subject: |
|
|
Ok I found my mistake. Apparently I was using $xajax->printJavascript('') instead of $xajax->getJavascript('')... |
|
Back to top |
|
master_kaos Smarty Regular
Joined: 02 Aug 2007 Posts: 54
|
Posted: Tue Dec 11, 2007 3:47 pm Post subject: |
|
|
Yes xajax and smarty are my 2 most used libraries for PHP
I don't know what I would do without either.
ALso in the php ajax functions I use $smarty->fetch alot so I can output templates through ajax calls |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|