We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11093
    • 50 Posts
    Hi all,
    I just wanna know if that possible to use modx api in a called ajax file, i saw there was a file in root directory who allow to connect easiest to database but not a instance modx ? is there a solution for my problem ? thank you

    ps: sorry for my poor english ^^
      • 18397
      • 3,250 Posts
      Take a look at the latest version of AjaxSearch as I believe it makes use of the index-ajax.php file.
        • 11093
        • 50 Posts
        yes, i know and i was using this snippet as an example but as you can see, they are not using api when display ajax results :
            if ($ajaxSearch) {
                $tbl_sc = "`{$table_prefix}site_content`";
                $tbl_dg = "`{$table_prefix}document_groups`";
            } else {
                $tbl_sc = $modx->dbConfig['dbase'] . ".`" . $modx->dbConfig['table_prefix'] . "site_content`";
                $tbl_dg = $modx->dbConfig['dbase'] . ".`" . $modx->dbConfig['table_prefix'] . "document_groups`";
            }
          • 11093
          • 50 Posts
          up
            • 11093
            • 50 Posts
            up
              • 11975
              • 2,542 Posts
              Hi,

              here is piece of code from docManager module, tvajax.php

               include_once ("../../../../manager/includes/config.inc.php");
               include_once(MODX_BASE_PATH."manager/includes/document.parser.class.inc.php");
               $modx = new DocumentParser;
              
              


              You have to create your own instance of modx

              :-)
                Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                • 11093
                • 50 Posts
                Salut,
                Merci beaucoup ca fonctionne et ma réponse est française ^^
                Ca fait plusieurs fois que je pose la question est l’on ne m’avait répondu ^^

                Pour la petite info ( peut-être est tu déja au courant ), lors de l’appel ajax au lieu d’appeler l’url simplement, appeler ceci celle-ci :
                index-ajax.php?q=assets/snippets/puborders/puborders.ajax.php

                permet l’inclusion automatique du fichier ’manager/includes/config.inc.php’.