Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[FIXED] JDom outside component 13 Mar 2012 14:52 #1589

  • M4d3L
  • M4d3L's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 45
  • Thank you received: 7
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.

Please Log in or Create an account to join the conversation.

Re: JDom outside component 26 Mar 2012 21:10 #1730

  • dmd
  • dmd's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 1
  • Thank you received: 1

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 :)
The following user(s) said Thank You: Tomaselli

Please Log in or Create an account to join the conversation.

Re: JDom outside component 20 Apr 2012 08:34 #2073

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Sorry for beiing long to answer.


I check this now.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: JDom outside component 20 Apr 2012 10:04 #2079

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
There were some errors that should be fixed now.


If you want to load JDom from a module, you are doing well.

You should notice that JDom can accept overrides of classes inside the same joomla instance.
So, if you want to open a specific classes tree, you can precise the extension in params :

JDom::_('html.fly.file', array(
    'dataKey' => 'image',
    'dataObject' => $slide,
    'width' => 'auto',
    'height' => 'auto',
    'indirect' => true,
    'root' => '[DIR_SLIDES_IMAGE]'


    'extension' => 'com_xxxx'		//HERE
    ));

By this way, you choose wich files to use, but this is optional for really specific uses.

It should works now.

EDIT : Regenerate your project.
The only affected file is : dom/dom.php
Coding is now a piece of cake
The following user(s) said Thank You: edwardcox

Please Log in or Create an account to join the conversation.

Last edit: by admin.
  • Page:
  • 1
Time to create page: 0.058 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started