Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Adding navigation

Johan Strydom edited this page Aug 13, 2021 · 2 revisions

Nav content

For the navigation you can simply modify the main.php or side.php files within the \content\navs\ folder as follows:

<?php 
namespace Tsama;
$this->m_catalog = array(
    LibraryCatalog::GetArticle('default'),
    LibraryCatalog::GetArticle('carousel'),
    LibraryCatalog::GetArticle('my-awesome-page',"Custom Title"),
);
?>

LibraryCatalog::GetArticle() allows you to set a custom title for your nav.

You can also add your own php file within navs where you can build the $this->m_catalog array with your custom articles.

Displaying the nav

In order to display the navs in your content you first need to load the nav service. The following code show how that can be done.

  $navService = new TsamaService();
  $navService->Load("nav","main");
  $nav = $navService->GetService();

Once the service is loaded you can call $nav->GetNavBar() to get a string containing the article anchors as part of an ul as follows

  $navBar = $nav->GetNavBar();
  echo $navBar;

or alternatively you can build your own nav as follows:

$articles = $nav->GetCatalog();

echo '<ul class="navbar-nav me-auto mb-2 mb-md-0">';
foreach($articles as $article){
	echo '<li class="nav-item text-nowrap">';
	echo $article->GetAnchor();
	echo '</li>';
}
echo '</ul>';

NEXT » Connecting to a database «

Clone this wiki locally