Welcome Guest, Not a member yet? Register   Sign In
Menu from mysql in view
#3

[eluser]Jason Stanley[/eluser]
If this menu is in its own little snippet then I don't think you are doing a great deal wrong. Its a pretty simple menu. If you convert the database object to an array then you would still have essentially the same..

Code:
<ul>
&lt;?php
if (count($menu)
{
foreach ($menu as $item)
{
  echo '<li>'. anchor($item['url'], $item['text']) .'</li>';
}
}
?&gt;
</ul>

The main thing to change is to stop calling the model from the view. Instead pass the view file a variable containing the menu object.

I would only do more in the model if the navigation was more complex. If there were submenus etc which required a bit more logic I would create an array then probably a helper function to convert the array into html.


Messages In This Thread
Menu from mysql in view - by El Forum - 01-27-2012, 01:03 AM
Menu from mysql in view - by El Forum - 01-27-2012, 02:21 AM
Menu from mysql in view - by El Forum - 01-27-2012, 03:10 AM
Menu from mysql in view - by El Forum - 01-27-2012, 08:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB