Search code examples
joomlajoomla2.5joomla-component

Joomla 2.5 component: How to set directory for media field in admin form?


I created a custom component, in the admin-form, I have a field to select a photo.

In administrator/models/forms/example.xml I can define that field:

<field name="photo" type="media"
    label="COM_EXAMPLE_FORM_LBL_PHOTO"
    description="COM_EXAMPLE_FORM_DESC_PHOTO" 
    filter="raw"
    directory="/images/example/photos" 
/> 

The Problem:
When I push the select button, the media manager's directory is set to /images, though.

I tried directory="JPATH_ROOT/images/example/photos" --> same result.

How can I set directory so that media manager would open /images/example/photos?


Solution

  • Try this:

    <field name="photo" type="media"
        label="COM_EXAMPLE_FORM_LBL_PHOTO"
        description="COM_EXAMPLE_FORM_DESC_PHOTO" 
        filter="raw"
        directory="example/photos" 
    /> 
    

    Note: I have only used example/photos