#1 October 10, 2018 6:37am

daansk44
Member
From: Amersfoort, The Netherlands
Registered: September 12, 2016
Posts: 42

Loop trought menu

Maby a really basic question. How can I call the complete menu (So I can loop trought it).
And second. I called a function

<?php
$hallo = new getNav();
?>

And I get this error (New install)

Fatal error: Uncaught Error: Call to undefined function getAll() in /home/xx/templates/layouts/_header.php:63 Stack trace: #0 
/home/xx/templates/layouts/default.php(1): include() #1 /home/xx/core/router.php(481): include('/home/franskrol...') #2 /home/xx/core/launch.php(133): include('/home/franskrol...') #3 /homexxl/site/index.php(3): include('/home/franskrol...') #4 {main} thrown in /home/xx/templates/layouts/_header.php on line 63

Offline

#2 October 11, 2018 10:54am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Loop trought menu

What is line 63 of your _header.php file that is throwing the error?

Offline

#3 October 11, 2018 12:31pm

daansk44
Member
From: Amersfoort, The Netherlands
Registered: September 12, 2016
Posts: 42

Re: Loop trought menu

Okay I change some code.

<!doctype html>
<?php
$menu = BigTreeCms::getNavByParent($variables);
?>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="<?= $bigtree["config"]["www_root"] . 'site/css/basic.css';?>">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <meta name="description" content="<?=$page["meta_description"];?>" />
	<meta name="keywords" content="<?=$page["meta_keywords"];?>" />
	<meta name="robots" content="index, follow"/>
	<meta name="application-name" content="FLXcms" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta property="og:title" content="<?= $page['title']; ?>" />
	<meta property="og:url" content="<?=$page['link'];?>" />
	<meta property="og:image" content="" />
	<meta property="og:description" content="<?=$page["meta_description"];?>" />
	<meta property="og:type" content="website" />
	<meta property="dc:language" content="nl" />
	<meta property="dc:source" content="<?=$page['link'];?>" />
	<meta property="dc:title" content="<?= $page['title']; ?>" />
	<meta property="dc:keywords" content="<?=$page["meta_keywords"];?>" />
	<meta property="dc:description" content="<?=$page["meta_keywords"];?>" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title> <?= $page['title']; ?></title>

  </head>
  <!-- Menu -->
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="/"><?= $page['title']; ?></a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
  <ul class="navbar-nav mr-auto">
    <?php
    foreach ($menu as $menuitem) { ?>
 
     <li class="nav-item">
        <a class="nav-link" href="<?=$menuitem["link"]?>"><?=$menuitem["title"];?></a>
      </li>
      
      <?php
    }
    ?>
    
    
      
    
     
    </ul>
    
  </div>
</nav>

Offline

#4 October 12, 2018 3:32pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Loop trought menu

That code is only 60 lines so I'm not sure where the error is occurring.

The BigTreeCMS::getNavByParent call doesn't look right though -- it should be accepting the parent ID as the first parameter (e.g. "0" if you want top level navigation).

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.