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

TOPIC:

Retrieve image path without Jdom 16 Feb 2013 23:32 #6793

  • etc
  • etc's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 132
  • Thank you received: 19
Hi everyone,

I have a module without Jdom. Now I need to display an image.
I know how to retrieve name of the image from database but I don't know
how to retrieve image path that was stored by component(generated by j-cook).
Direct path to the file is not possible of course.

thanks a lot

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

Re: Retrieve image path without Jdom 17 Feb 2013 09:45 #6794

  • etc
  • etc's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 132
  • Thank you received: 19
After some investigation I have got some idea but I am not sure if it safe. Actually it is copy from j-cook classes.
function downloadUrl($path) {

  $dirPattern = "DIR_FOLDERNAME";
  $path = "[" . $dirPattern . "]" . $path;
  $size	= "0x100";
	$urlimg = JURI::base(true) . "/index.php?option=com_yourcomponent&task=file"
	"&size=" . $size
      .	"&path=" . $path;
			
		return $urlimg;
			}
$path
in function header is image name.

Comments are welcome.

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

Last edit: by etc.

Re: Retrieve image path without Jdom 17 Feb 2013 10:56 #6796

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Yes, I think it is correct... And safe because the full path is hidden.
You are using a requests trough index.php. Perfect.

I think this function is missing in Cook.
You found this is JDom, correct ?

Because you can use JDom for this.

I do not remember how, but to see how :

In the builder, put your image field in a grid, then choose link = download.
Then it will generate the right URL link automatically. You can put preview to false if you want to see only the file name without the forlder marker.
Coding is now a piece of cake

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

Re: Retrieve image path without Jdom 17 Feb 2013 11:54 #6798

  • etc
  • etc's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 132
  • Thank you received: 19
Yes I found the function in JDom.

I would do it in builder but unfortunatelly J-cook does not generate modules at the moment so I needed created it on my own.
To be honest I can not using JDom in my module so I needed call it somehow and safely.

thanks

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

Re: Retrieve image path without Jdom 17 Feb 2013 15:22 #6799

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
I don't understand why Joomla do not have facilities in the core to acces indirecly the files and images.

To be honest I can not using JDom in my module so I needed call it somehow and safely.


In coming 2.5, cook is using JLoader. This means that only one line is required to register all the files of your component. (only request loader.php of your component and that's it).

With JLoader, your requested class files are not loaded in memory until they are used. So this is really nice when you have huge components, and very nice because you do not need to make your include_once() in the functions everywhere in classes / modules, etc...

This is I think one of the most important features in 2.5

JDom embed it's own loader for the moment because JLoader is still lacking a little bit (even in 3.0), but when Joomla will handle it properly JDom will use the native Loader.

Anyway, in 2.5, you can use JDom in multiples components much more easily.
I may also create JDom plugin, but maybe better in the Joomla core if the team is accepting.

JDom can now be instancied (not only static), and will stay in JApplication (same as JInput) :
$app->dom;

By the way, you can find JDom in the GitHub repository :
github.com/Cook-Self-Service/joomla-plat...libraries/joomla/dom
This is the current JDom version available in Cook.
Coding is now a piece of cake

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

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

  Joomla Developpers won't be able to live without J-Cook's Component Creator! Check it out - it'll save you a heap of time coding so you can concentrate on the creative part of developing!
Mind-Your-Biz-Online

Get Started