Welcome Guest, Not a member yet? Register   Sign In
Navigation and Templating Question
#1

[eluser]eedfwChris[/eluser]
Hey everyone! I am trying to migrate to using the template parser for various reasons but I haven't quite gathered how to make this work how I like it...

Basically what I have is a shell (parent_view.php) which other views are called "in to" such as a login form or body for a specific element. What I am trying to duplicate is the navigation "selection" via css classes.

My assumption is that when you start using the parser that all php code be out of your views. Does anyone have any ideas on how to replicate (attractively) what I am doing with the if statements and css classes as listed below without putting the php into the view while still giving the designer some control over the style of the navigation (ie: not hard coding it into the controller)?

Code:
<!-- Sliding Login Form -->
{sliding_login_form}
<!-- End Sliding Login Form -->

<!-- Start Navigation -->
<ul>
<li &lt;?php if ($uri == 'about_us') { echo 'class="selected"'; } ?&gt;><a href="&lt;?php echo site_url('/about_us/'); ?&gt;">About Us</a></li>
<li &lt;?php if ($uri == 'scheduler') { echo 'class="selected"'; } ?&gt;><a href="&lt;?php echo site_url('/scheduler/'); ?&gt;" class="important">Schedule Appointment</a></li>
<li &lt;?php if ($uri == 'services') { echo 'class="selected"'; } ?&gt;><a href="&lt;?php echo site_url('/services/'); ?&gt;">Services</a></li>
<li &lt;?php if ($uri == 'careers') { echo 'class="selected"'; } ?&gt;><a href="&lt;?php echo site_url('/careers/'); ?&gt;">Careers</a></li>
<li &lt;?php if ($uri == 'contact_us') { echo 'class="selected"'; } ?&gt;><a href="&lt;?php echo site_url('/contact_us/'); ?&gt;">Contact Us</a></li>
</ul>
&lt;!-- End Navigation --&gt;

&lt;!-- Start Body --&gt;
{body}
&lt;!-- End Body --&gt;
#2

[eluser]sophistry[/eluser]
This view library with support for including CSS might be helpful.
#3

[eluser]esra[/eluser]
[quote author="sophistry" date="1185394133"]This view library with support for including CSS might be helpful.[/quote]

Off topic but it would probably be neat to extend the Parser library to support View library features.

There is a article and a Menu class on the Wiki by Tamer:

http://codeigniter.com/wiki/DynamicMenu/

I have not used the class myself, but it might solve your needs.

A different approach might be to create a table called menus based on the Adjacency List Model or Nested Sets Model, then populate the menu block dynamically using a query and foreach loop. This would put you in a position where you could changethe menu items from an Admin module or possibly maintain multiple menus for use on different templates. The menu block could be made an independent view fragment by writing a view-specific helper to handle menu item population.

What we have not seen yet used extensively on CI is better use of plugins. It might be possible to build one or more plugins that loaded off-the-shelf menu solutions.




Theme © iAndrew 2016 - Forum software by © MyBB