Jump to content

Runaway navbar.


Tinaa
Go to solution Solved by 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>
Edited by Tinaa
Link to comment
Share on other sites

  • Solution

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.