Tinaa Posted October 10, 2013 Share Posted October 10, 2013 (edited) Hello! So, I have this code, but the navbar will not show up. I got an explanation that get_$navbar needs to be put in my index.tpl.php, but in my head that doesn´t look right - the other ones show up, so... Then I also was told that it neds to be put in my config.php, and then he talked about functions.php... I can´t fix it, I don´t get coding. This is my original code, I don´t get what he wants from me. Help anyone? I would really appreciate it, I´m not asking to cheat really, I have problems with learning some things and this time I got ahead of myself and can´t sort it out. config.php (slightly changed to cover my ass ) $sky['navbar'] = array( 'class' => 'nb-plain', 'items' => array( 'home' => array('text'=>'Home', 'url'=>'me.php', 'title' => 'Me'), 'pics' => array('text'=>'Pics', 'url'=>'pics.php', 'title' => 'Pics'), 'source'=> array('text'=>'Source', 'url'=>'source.php', 'title' => 'Source'), ), 'callback_selected' => function($url) { if(basename($_SERVER['SCRIPT_FILENAME']) == $url) { return true; } } ); functions.php function get_navbar($menu) { $html = "<nav>\n<ul class='{$menu['class']}'>\n"; foreach($menu['items'] as $item) { $selected = $menu['callback_selected']($item['url']) ? " class='selected' " : null; $html .= "<li{$selected}><a href='{$item['url']}' title='{$item['title']}'>{$item['text']}</a></li>\n"; } $html .= "</ul>\n</nav>\n"; return $html; index.tpl.php <body> <div id='wrapper'> <div id='header'><?=$header?></div> <div id='navbar'><?=$navbar?></div> <div id='main'><?=$main?></div> <div id='footer'><?=$footer?></div> </div> </body> Edited October 10, 2013 by Tinaa Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 10, 2013 Share Posted October 10, 2013 I can't tell how or if this is all glued together, but where is $header, $main and $footer defined? Quote Link to comment Share on other sites More sharing options...
Tinaa Posted October 10, 2013 Author Share Posted October 10, 2013 I can't tell how or if this is all glued together, but where is $header, $main and $footer defined? In the config.php (There are way to many files for me in this, he has made it to big..) Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 10, 2013 Share Posted October 10, 2013 Just an educated guess, but maybe this at the end of the config: $navbar = get_navbar($sky['navbar']); Or alternately maybe this in the index: <div id='navbar'><?=get_navbar($sky['navbar'])?></div> Quote Link to comment Share on other sites More sharing options...
Solution Tinaa Posted October 10, 2013 Author Solution Share Posted October 10, 2013 Just an educated guess, but maybe this at the end of the config: $navbar = get_navbar($sky['navbar']); Or alternately maybe this in the index: <div id='navbar'><?=get_navbar($sky['navbar'])?></div> God damnit, it WAS the index, hahaha! I was being stubborn because the other ones did not look like that. Thank you SO very much, now I get it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.