Hello,
This I am trying to create an effective navigation code in CI. Let's say I have 10 shared pages that have the same navigation. Do I have to add the "## navigation link" codes over and over again (10 times ?)
controllers/page.php
<?php
class Page extends CI_Controller {
public function __construct(){
parent::__construct();
## load the url helper object
$this->load->helper("url");
}
public function index()
{
## define the location of your css directory in reference to the application directory
$data = array(
'style' => base_url().'assets/css/style.css',
'connection' => base_url().'assets/images/connection.jpg',
'collaboration' => base_url().'assets/images/collaboration.jpg',
'solution' => base_url().'assets/images/solution.jpg',
'connectionUrl' => base_url().'index.php/connection/',
'collaborationUrl' => base_url().'index.php/collaboration/',
'solutionUrl' => base_url().'index.php/solution/'
);
## navigation link
$datanav = array(
'nav' => base_url().'assets/css/nav.css',
'logo2' => base_url().'assets/images/logo2.png',
'index' => base_url(),
'connectionUrl' => base_url().'index.php/connection/',
'collaborationUrl' => base_url().'index.php/collaboration/',
'solutionUrl' => base_url().'index.php/solution/',
'foUrl' => base_url().'index.php/connection/fo',
'wirelessUrl' => base_url().'index.php/connection/wireless',
'cloudUrl' => base_url().'index.php/collaboration/cloud',
'emailUrl' => base_url().'index.php/collaboration/email',
'vconUrl' => base_url().'index.php/collaboration/vcon',
'sharepointUrl' => base_url().'index.php/collaboration/sharepoint',
'crmUrl' => base_url().'index.php/collaboration/crm',
'voiceUrl' => base_url().'index.php/collaboration/voice',
'networkUrl' => base_url().'index.php/solution/network',
'systemUrl' => base_url().'index.php/solution/system',
'surveillanceUrl' => base_url().'index.php/solution/surveillance',
'searchbutton' => base_url().'assets/images/search button.jpg'
);
$this->load->view('templates/navigation', $datanav);
$this->load->view('homepage', $data);
}
}
?>
views/template/navigation.php
<link href= "<?php echo $nav; ?>" rel="stylesheet" type="text/css" media="screen">
<div id="navigation">
<div id="logo"><img src="<?php echo $logo2; ?>" width="160" height="60"></div>
<div id='cssmenu'>
<ul>
<li class='active'><a href='<?php echo $index; ?>'>|    Home    |</a></li>
<li class='has-sub'><a href='<?php echo $index; ?>'>    Product & Services    |</a>
<ul>
<li class='onelayer'><a href='<?php echo $connectionUrl; ?>'>    Connection       ></a>
<ul>
<li class='onelayer'><a href='<?php echo $foUrl; ?>'>    Fiber Optic</a></li>
<li class='onelayer'><a href='<?php echo $wirelessUrl; ?>'>    Wireless</a></li>
</ul>
</li>
<li class='onelayer'><a href='<?php echo $collaborationUrl; ?>'>    Collaboration         ></a>
<ul>
<li class='onelayer'><a href='<?php echo $cloudUrl; ?>'>    Cloud</a></li>
<li class='onelayer'><a href='<?php echo $emailUrl; ?>'>    Email</a></li>
<li class='onelayer'><a href='<?php echo $vconUrl; ?>'>    VCON</a></li>
<li class='onelayer'><a href='<?php echo $sharepointUrl; ?>'>    Sharepoint</a></li>
<li class='onelayer'><a href='<?php echo $crmUrl; ?>'>    CRM</a></li>
<li class='onelayer'><a href='<?php echo $voiceUrl; ?>'>    Voice</a></li>
</ul>
</li>
<li class='onelayer'><a href='<?php echo $solutionUrl; ?>'>    Solution         ></a>
<ul>
<li class='onelayer'><a href='<?php echo $networkUrl; ?>'>    Network Solution</a></li>
<li class='onelayer'><a href='<?php echo $systemUrl; ?>'>    System Solution</a></li>
<li class='onelayer'><a href='<?php echo $surveillanceUrl; ?>'>    Surveillance</a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'>    Agent    |</a></li>
<li><a href='aboutus.php'>    About Us    |</a></li>
<li><a href='contactus.php'>    Contact Us    |</a></li>
</ul>
</div>
<div id="search">
<input type="text" name="search"></div>
<div id="sbutton"><img src="<?php echo $searchbutton; ?>"></div>
</div>
</div>