Jump to content

Runaway navbar.


Tinaa

Recommended Posts

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 ;D )

$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>
Link to comment
https://forums.phpfreaks.com/topic/282875-runaway-navbar/
Share on other sites

 

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. ;D

 

Thank you SO very much, now I get it!

Link to comment
https://forums.phpfreaks.com/topic/282875-runaway-navbar/#findComment-1453485
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.