Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple PHP relative path in a Joomla Tutorial
    text
    copied!<p>Considering this article <a href="http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4_-_Creating_an_Administrator_Interface#Example_roll-out" rel="nofollow">Developing a MVC component for Joomla</a>, following is the code to include the general template,</p> <pre><code>$pathToGeneralView = strchr(dirname(__FILE__), dirname($_SERVER['SCRIPT_NAME'])); $pathToGeneralView = str_replace(dirname($_SERVER['SCRIPT_NAME']),'.',$pathToGeneralView ); $pathToGeneralView = $pathToGeneralView . "/../../general/"; &lt;-- returning path from current position. ... &lt;?php require_once $pathToGeneralView . 'navigate.header.php'; ?&gt; &lt;P&gt;Do something &lt;?php require_once $pathToGeneralView . 'navigate.footer.php'; ?&gt; </code></pre> <p>With the file system hierarchy,</p> <pre><code>./com_compname/views/general/navigate.header.php &lt;-- sniplet code for the header ./com_compname/views/general/navigate.footer.php &lt;-- sniplet code for the footer ./com_compname/views/mngtable1/view.html.php ./com_compname/views/mngtable1/tmpl/default.php * ./com_compname/views/mngtable2/view.html.php ./com_compname/views/mngtable2/tmpl/default.php * </code></pre> <p>Since the general template component is just under the <code>../../general</code> folder, why do the author bothering to use strchr, str_replace to deal with the folder path? Isn't it <code>../../general/navigate.header.php</code> or <code>../../general/navigate.footer.php</code> enough?</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload