2

I'm working on a basic module to display an image carousel. The module itself works well, but what I want to do now is create a new folder called 'carousel' within the root 'images' folder when the module installs.

I've researched this a lot here (I apologise if this is a duplicate question) and from searches, but no matter what I try I can't get it to work.

I have this in the manifest file.

<scriptfile>script.php</scriptfile>

And I've created a script.php file. Here's what I have so far:

<?php
// No direct access to this file
defined('_JEXEC') or die;

  class mod_CarouselInstallerScript
  {
    function install($parent) 
    {
      $destination = JPATH_SITE.'/'."images";
      $folder_name = "carousel";
      JFolder::create($destination .'/'. $folder_name, 0755);
    }
  }
?>

I've tried various versions of this found here and in Joomla documentation.

What am I missing?

11
  • Are you sure it's even being executed? Can you try adding var_dump('foobar'); inside the function and check your Network tab in the browser console to see if you see that being returned?
    – Lodder
    Commented Aug 27, 2019 at 9:27
  • Hi @Lodder, thank you for your reply. I've done as you suggested and, no it's not returned in the Network tab in the browser console.
    – JJBW
    Commented Aug 27, 2019 at 10:12
  • In which case your class name may be incorrect. Can you provide the XML <name> value for your module?
    – Lodder
    Commented Aug 27, 2019 at 11:24
  • Hi @Lodder - here it is - <name>RRM Carousel</name>
    – JJBW
    Commented Aug 27, 2019 at 11:31
  • Try replacing class mod_CarouselInstallerScript with class mod_Rmg_carouselInstallerScript
    – Lodder
    Commented Aug 27, 2019 at 11:48

1 Answer 1

1

Thank you to @Lodder for providing a solution, very much appreciated.

@Lodder suggested my class name may be incorrect and said to try 'replacing class mod_CarouselInstallerScript with class mod_Rmg_carouselInstallerScript'.

I changed my class to mod_RRM_carouselInstallerScript which solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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