Considering this article Developing a MVC component for Joomla, following is the code to include the general template,
$pathToGeneralView = strchr(dirname(__FILE__), dirname($_SERVER['SCRIPT_NAME']));
$pathToGeneralView = str_replace(dirname($_SERVER['SCRIPT_NAME']),'.',$pathToGeneralView );
$pathToGeneralView = $pathToGeneralView . "/../../general/"; <-- returning path from current position.
...
<?php require_once $pathToGeneralView . 'navigate.header.php'; ?>
<P>Do something
<?php require_once $pathToGeneralView . 'navigate.footer.php'; ?>
With the file system hierarchy,
./com_compname/views/general/navigate.header.php <-- sniplet code for the header
./com_compname/views/general/navigate.footer.php <-- 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 *
Since the general template component is just under the ../../general folder, why do the author bothering to use strchr, str_replace to deal with the folder path? Isn’t it ../../general/navigate.header.php or ../../general/navigate.footer.php enough?
Thanks.
When adding paths in joomla use the JURI class:
http://docs.joomla.org/JURI/base