문제

My custom component needs a certain path, say /images/example/photos.

How can I create it on installation, but only if it doesn't exist yet?

도움이 되었습니까?

해결책

You will need an install script. To get is set up, have a look at this:

Adding an Install/Uninstall/Update script file

You can remove all the functions but keep the install function. Your final install function should look like this:

function install($parent) {

    jimport('joomla.filesystem.folder');
    jimport('joomla.filesystem.file');

    if(!JFolder::exists(JPATH_ROOT . '/media/images/example/photos')) {
         $path = JPATH_SITE . '/media/images';
         $folder = 'example/photos';
         JFolder::create( $path .'/'. $folder, 0755 );
    }
}

Hope this helps

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top