# Get current script's and its parent folder path

Is there any Joomla way to return the path or parent's folder path of a current script?

So far when needed, I am using the Joomla Constants and building manually the remaining of the path. It's also possible with php, but I am wondering if there is any Joomla API functionality to get around this.

So let's say I am inside a template override:

templates/mytemplate/html/my_component/my_view/template.php


And want to create a new directory inside the parent "view" directory in order to place a file inside it, like so:

templates/mytemplate/html/my_component/my_view/newDir/newfile.ext


Then I want to call/link that new newFile.ext from the template.php file.

Is there any Joomla way to get the path of my_view dir?

• Can you elaborate your question with more details, your question is broad to understand.. – Nagarjun May 26 '15 at 16:28
• @Nagarjun:: sure - I added a simple example. – FFrewin May 26 '15 at 16:43
• I am not sure Joomla way, but you could simply use dirname ( __FILE__ ) – Nagarjun May 26 '15 at 16:47
• And to get parent of current directory dirname( dirname(__FILE__) ); – Nagarjun May 26 '15 at 16:49
• Dirname is always an option. But wondering if there is any Joomla API functionality. Think there is something similar in WP. – FFrewin May 26 '15 at 16:52

There is no Joomla API to get the current directory. There is no reason for it since dirname(__FILE__) works perfectly fine :-)
If you need to sanitise the filename, you can use JPath::clean().