0

I have component which needs a slider. I`ve chosed carousel but how to add it in the frontend part of the component on installation ? Tried to put it in the administrator part but the scripts can't be reached this way.

2
2

Your component has a manifest file (component_name.xml). In that file you list the files you want the installer to upload and locate.

So you create a section that looks something like this:

<media destination="com_whatever" folder="media">
<folder>js</folder>
</media>

That tells the installer to install the folder 'js' into /media/com_whatever area of Joomla (do I really need to point out that you need to substitute your component's name for com_whatever?) so it can be ready for use.

Then in the template for the view for your controller (front-end) you can ensure Joomla adds that js by calling addScript to add your script to the list.

You want to do it that way because that will allow a user to override your choice as part of a general template override for your component (and please don't be That Guy who thinks the way they want the output to look is the only right and proper way for it to look -- let the user have some say in the design and layout of their own site).

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.