3

I am developing a custom module, and I need this module to show selected some pictures selected in the backend. So, I declare a parameter with type "imagelist" in my module xml file.

    <fields name="params">
        <fieldset name="advanced">
            <field
                name="project1-image"
                type="imagelist"
                directory="???\images"
                label="..."
                description="..." />
        </fieldset>
    </fields>

The problem is the "images" directory is located in some Joomla template. Is there some constant like "JPATH_COMPONENT" or "JPATH_BASE" pointing to currently applied template to site? Or do I need to force site admin to write filename and find it in php file of my module (which seems like a bad solution).

1

If you enter a directory value, it will be relative to the root of you Joomla installation. Thus, if you want to get images from your template, simply use the following:

directory="templates/TEMPLATE_NAME/images"

This can only be used for a predefined template and cannot be used for the current template.

For this, you will need to create a custom form field. I would suggest copying the imagelist form field and changing the paths

5

Look at https://gist.github.com/leFlea-snippets/4602845

PHP: Joomla - Get active template path

// Get active template path from anywhere on Joomla: 
$app    = JFactory::getApplication();
$path   = JURI::base(true).'/templates/'.$app->getTemplate().'/';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.