1
frankblack
XAJAX? Anyone?
  • 2009/5/23 11:00

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Is here anyone familiar with XAJAX? There are a few minor things I have to solve. Maybe this could be interesting for others as well?

My module is using XAJAX in three files. Two normal module files and one block file. xajax.inc.php has to be included with require_once. I had to do this in all three files, but this gave me the problem that the xajax-class could not be redeclared when a module page and the block was displayed at the same time. So I searched all the xajax-files and changed require to require_once. So the fatal error went away. Next problem was that processRequest() has to be there only ONE time and not in all the files. But I managed this also. The big question is: where is the best place for including the file and placing processRequest() without hacking core files?

Any help is appreciated.

2
trabis
Re: XAJAX? Anyone?
  • 2009/5/23 13:46

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Can we see code?

You could use like
if (!defined('XAJAX_INCLUDED') {
    require 
'your/xajax/files.php';
    
define('XAJAX_INCLUDED'"Yes, so please do not include me again");    
}

3
blindman
Re: XAJAX? Anyone?
  • 2009/5/23 15:07

  • blindman

  • Not too shy to talk

  • Posts: 119

  • Since: 2005/6/26


First, I think Xajax is great tool.
About your answer, did you tried $xoops_module_header to declare xajax stuff?
Don't follow me. I'm lost too.

4
frankblack
Re: XAJAX? Anyone?
  • 2009/5/23 15:51

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Code for module page:
require_once DEBASER_ROOT.'/include/functions.php';
require_once 
DEBASER_ROOT.'/xajax/xajax_core/xajax.inc.php';
$xajax = new xajax();
if (
$playlistyes == 1) {
$rqst1 = &$xajax->register(XAJAX_FUNCTION'xajaxupdate');
$xoopsTpl->assign('playlistyes'true);
}
if (
$innerdisplay == 1) {
$rqst2 = &$xajax->register(XAJAX_FUNCTION'xajaxinnerdisplay');
$xoopsTpl->assign('innerdisplay'true);
}
// Uncomment the next line for debugging purposes
$xajax->setFlag('debug'true);
$xajax->processRequest();
$Xjavapath XOOPS_URL.'/modules/debaser/xajax';
$xajaxjava $xajax->getJavascript($Xjavapath);
$xoopsTpl->assign('xoops_module_header'$xajaxjava);


Code for block:
require_once XOOPS_ROOT_PATH.'/modules/debaser/include/functions.php';
require_once 
XOOPS_ROOT_PATH.'/modules/debaser/xajax/xajax_core/xajax.inc.php';
$xajaxb = new xajax();
$radio = &$xajaxb->register(XAJAX_FUNCTION'xajaxradio');
// Uncomment the next line for debugging purposes
$xajaxb->setFlag('debug'true);
if (!
preg_match("/debaser/"dirname($_SERVER['PHP_SELF']))) $xajaxb->processRequest();
$Xjavapath XOOPS_URL.'/modules/debaser/xajax';
$xajaxjavaradio $xajaxb->getJavascript($Xjavapath);
$block['xajax'] = $xajaxjavaradio;


The only problem is, that has to be only ONE processRequest(), but if the block is displayed inside the module (on that specific page) then there are two processRequest(). I guess I have to move the whole xajax into a framework.

5
blindman
Re: XAJAX? Anyone?
  • 2009/5/23 18:37

  • blindman

  • Not too shy to talk

  • Posts: 119

  • Since: 2005/6/26


Keeping only one processRequest() is not that easy indeed. I used xajax but not in a block, so I didn't face this issue.
I found something like
$xoopsTpl->assign'xoops_module_header' '.XOOPS_URL.'/modules/mysearch/css/style.css" />.XOOPS_URL.'/modules/mysearch/js/scriptaculous/lib/prototype.js">.DELTA_URL.'/modules/mysearch/js/scriptaculous/src/scriptaculous.js">'.@$xoopsTpl->get_template_vars("xoops_module_header") );

in mysearch module but this way you can add something at the end or beginning of xoops_module_header.

Maybe you should check if xoops_module_header contains xajax assignment code, put a sign like a separator in module header part( like ), explode xoops_module_header into block part of script, add some code and reassign xoops_module_header. For now nothing else cross my mind.
Don't follow me. I'm lost too.

Login

Who's Online

410 user(s) are online (325 user(s) are browsing Support Forums)


Members: 0


Guests: 410


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits