M4d3L wrote:
I try to use JDom from a module but I have error : JError: Unable to load JDom class : JDomHtml
I include it in my module like :
if (!class_exists('JDom'))
require_once(JPATH_ADMINISTRATOR. '/components/com_building/dom/dom.php');
do I miss something or?
in an other hand, I think you should think about put JDom into a Library package and not be a part of a component. (In case we have many Component using JCook.
I second that, as I have just started my first project with j-cook and have straight away run into the problem that when I am developing a module I want to use JDom's html.fly.file to display an image from within the module. When I try to include the JDom using this code:
$slides[$k]['image_url'] = JDom::_('html.fly.file', array(
'dataKey' => 'image',
'dataObject' => $slide,
'width' => 'auto',
'height' => 'auto',
'indirect' => true,
'root' => '[DIR_SLIDES_IMAGE]'
));
I get the error:
JError: Unable to load JDom class : JDomHtml
Then when I try to include the class JDomHtml like this:
if (!class_exists('JDom'))
require_once(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_hicslider'.DS.'dom'.DS.'dom.php');
if (!class_exists('JDomHtml'))
require_once(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_hicslider'.DS.'dom'.DS.'html.php');
I get the same error:
JError: Unable to load JDom class : JDomHtml
This is because JDom::searchFile() is using constants JPATH_ADMINISTRATOR to build the path to the class file, but since the module is being used on the home page, the value of JPATH_ADMINISTRATOR points to com_content instead of com_hicslider.
I think that centralizing JDom or designing it so it can be used outside of the component is necessary. This could be achieved by using variables instead of constants in JDom::searchFile() or using JPATH_ROOT instead of JPATH_ADMINISTRATOR.
I would like to know if there are any work-arounds that will allow me to use JDom in a module on a page that does not use the j-cook component. For now I will just make my image link directly to the image file, but I would not like to do this for every project, I would rather use JDom like it should be used.
Thank you