Answer the question
In order to leave comments, you need to log in
How to include Joomla 3 classes in modules and components?
Greetings!
Do not judge strictly, the second day I write in php and even a module for Joomla 3.2.
The essence of the question is this: the module represents a small outline of the form, when changing the fields of which ajax sends a request to the php script, which must take the fields from the database and check the compliance of these fields.
The class itself for accessing the database and getting a list of objects is located in another file (controler.php).
In the case of the main file of the mod_calctrans module, it is possible to connect the file without problems and the method works
include_once JPATH_ROOT.'/modules/mod_calctrans/controller.php';
Warning: include_once(JPATH_ROOT/modules/mod_calctrans/controller.php) [function.include-once]: failed to open stream: No such file or directory in V:\home\dev.local\www\modules\mod_calctrans\ajax. php on line 5
Warning: include_once() [function.include]: Failed opening 'JPATH_ROOT/modules/mod_calctrans/controller.php' for inclusion (include_path='.;C:\php\pear') in V:\home\ dev.local\www\modules\mod_calctrans\ajax.php on line 5
sajbjdsadjbdjasjsdj
Answer the question
In order to leave comments, you need to log in
I advise you to read first: joomla-book.ru/development/creating-modules/module...
It also writes in English letters on the screen that PHP does not find the file JPATH_ROOT/modules/mod_calctrans/controller.php
Judging by the construction "define('_JEXEC', 1) or die('...');" in line 3 of ajax.php you are calling it directly from the browser. This means that JPATH_ROOT is not defined.
Read about Joomla's inner workings. Unfortunately, I can not advise literature, because. I haven't dealt with this CMS for a long time.
you can't just take and make a direct request to the file .../modules/mod_calctrans/ajax.php
when I need to make an AJAX request, I usually do this: I create a component for joomla, I create an AJAX request handler in it. I address something like this: index.php?option=com_component&task=task&tmpl=component&no_html=1&"+Math.random(). Thus I get the answer without extra code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question