Hi there,
I'm writing my first module, it ties into FEU to allow users to add and edit module content (much like the News fesubmit) and I'd like to use icons in the same way that I can in the admin pages with $gCms->variables['admintheme']->DisplayImage
I'm quite happy to use my own icons (I can't help but notice that modules such as MenuManager, FrontEndUsers, ModuleMaker etc have folders of images) but I can't figure out how to reference the images. I haven't managed to find any code in the aforementioned modules doing so either...
So, two questions really:
(a) Is there a 'DisplayImage' equivalent that I should use when outputting a front end page?
(b) If not, how do I get the folder of the module to access the image? Guessing it starts with $gCms-> but haven't managed to get much further than that! ;)
Cheers all,
Phil
[SOLVED] Using custom images with a module
[SOLVED] Using custom images with a module
Last edited by tallphil on Mon May 31, 2010 7:39 am, edited 1 time in total.
Re: Using custom images with a module
Update:
I've used the following to generate the base directory of my module:
This still seems a bit pants, anyone know a better way?
I've used the following to generate the base directory of my module:
Code: Select all
$moduledir = $gCms->config['root_url'].DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.
'< module name >'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;
Re: Using custom images with a module
Code: Select all
$moduledir = dirname(__FILE__);
To refer to your own module images it depends on in what context the image will be displayed.
I mean if it is displayed in a backend panel you create the image like this:
Code: Select all
$img = '<img src="../modules/[MODULENAME]/images/img.gif" />';
Code: Select all
$img = '<img src="modules/[MODULENAME]/images/img.gif" />';
The $gCms->variables['admintheme']->DisplayImage stuff is only to display an icon of the current used backend theme.
Notice that the image need an url.tallphil wrote:Code: Select all
$moduledir = $gCms->config['root_url'].DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR. '< module name >'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;
No path.
That means using DIRECTORY_SEPARATOR in urls is no good idea.
Try this instead:
Code: Select all
$img_dir = $gCms->config['root_url'] ."/modules/[MODULENAME]/images/";
Re: Using custom images with a module
Thanks NaN! Using your solution at the end (which is what I had wound up using independently) seems to work fine, and it's good to know that I'm not unnecessarily reinventing the wheel! 
