Welcome, Guest
Username: Password: Remember me

TOPIC: Need help calling JDOM in Module

Need help calling JDOM in Module 07 Jul 2021 14:25 #15847

  • organicwebs
  • organicwebs's Avatar
  • Offline
  • Premium Member
  • Chris
  • Posts: 126
  • Thank you received: 20
  • Karma: 8
Hi,
I'm creating a module for my component and thought I would use the JDom to call up an image.

I'm using this as document page as a guide... www.j-cook.pro/index.php/m/module

My component is called com_organicshop. My image field is "main_image".

In my module default.php I have...
// Set up the component for JDom
	$dom = JDom::getInstance();
	$dom->set('extension', 'com_organicshop');
Is the "extension" bitcorrect?

Also
<?php // Item Image
	echo JDom::_('html.fly.file', array(
	   // Furnish the image relative path
	  'dataValue' => $item->main_image,				 
          // Define as indirect, with the root directory alias
	  'root' => '[DIR_FILES_MAIN_IMAGE]',
	  'indirect' => true,
          // Some options for Thumb creation
	  'height' => 50,
	  'width' => 50,
	  'attrs' => array('center','crop','fit'),								
));?>

But the JDom isn't showing the image - it is not rendering. Instead I'm getting this output...
<img src="/index.php?option=com_organicshop&amp;task=file&amp;size=50x50&amp;attrs=center:1,crop:1,fit:1&amp;path=[DIR_FILES_MAIN_IMAGE]/shoelaces.jpg">
Any ideas?
Just call me Chris :)
Last Edit: 07 Jul 2021 14:27 by organicwebs.
The administrator has disabled public write access.

Need help calling JDOM in Module 07 Jul 2021 14:52 #15848

  • organicwebs
  • organicwebs's Avatar
  • Offline
  • Premium Member
  • Chris
  • Posts: 126
  • Thank you received: 20
  • Karma: 8
I worked it out...

'indirect' needed to be "false"... and 'root' needed to be "DIR_TABLE_FIELD"
<?php // Item Image
	echo JDom::_('html.fly.file', array(
	   // Furnish the image relative path
	  'dataValue' => $item->main_image,				 
	  // Define as indirect, with the root directory alias
	  'root' => '[DIR_ITEMS_MAIN_IMAGE]',
	  'indirect' => false,
	  // Some options for Thumb creation
	  'height' => 50,
	  'width' => 50,
	  'attrs' => array('center','crop','fit'),								
));?>

Pretty nifty. B)

I'm still discovering these little gems in JCook!
Just call me Chris :)
The administrator has disabled public write access.

Need help calling JDOM in Module 21 Jul 2021 20:59 #15849

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 294
  • Thank you received: 126
  • Karma: 48
good work :)
The administrator has disabled public write access.
Time to create page: 0.090 seconds

Get Started