View path inside default.php in joomla component
I'm building a component view in Joomla and I'm using a lot of JS in the file inside the component myview/tmpl/default.php.
Where is the best folder to store a separate JS file in a component and how to get a link to that file inside the default.php
Answer
Solution:
The recommended location for any web accessible media (images, javascript, css etc) required by a Joomla! Extension (component, module etc) is the
/media
directory. This is covered in the Manifest documentation on the Joomla! docs website.To put it simply, in your extensions directory include a directory called
media
(or something meaningful to you). In that store all of your web accessible content, you can even have sub-directories likeimages
orjs
orcss
or all of them.Then in your manifest XML add the
media
element, like:The Joomla installer will then create a folder for you inside
/media
calledcom_example
, then you can access all your media files with calls like:or
Answer
Solution:
You can try this
Answer
Solution:
This will give you path to components/CURRENT COMPONENT.
Source