I am using the "editorial"-theme https://github.com/bludit-themes/editorial and I want to write a plugin where the original navigation of the editorial-theme is used in the sidebar.
Take a look here https://html5up.net/uploads/demos/edito ... ments.html and you see that originally the childs of a (parent) page are toggled with a down-arrow and shown as a submenu.
The original markup for this is:
Code: Select all
<nav id="menu">
<header class="major">
<h2>Menu</h2>
</header>
<ul>
<li>
<span class="opener">Submenu</span>
<ul>
<li><a href="#">Lorem Dolor</a></li>
<li><a href="#">Ipsum Adipiscing</a></li>
</ul>
</li>
<li><a href="#">Etiam Dolore</a></li>
<li><a href="#">Adipiscing</a></li>
</ul>
</nav>
Here's the code of the whole plugin so far
Code: Select all
<?php
class pluginMyNavigation extends Plugin {
public function init()
{
// Fields and default values for the database of this plugin
$this->dbFields = array(
'label'=>'Static Pages',
'homeLink'=>true
);
}
// Method called on the settings of the plugin on the admin area
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$L->get('This title is almost always used in the sidebar of the site').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('Home link').'</label>';
$html .= '<select name="homeLink">';
$html .= '<option value="true" '.($this->getValue('homeLink')===true?'selected':'').'>'.$L->get('Enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('homeLink')===false?'selected':'').'>'.$L->get('Disabled').'</option>';
$html .= '</select>';
$html .= '<span class="tip">'.$L->get('show-the-home-link-on-the-sidebar').'</span>';
$html .= '</div>';
return $html;
}
// Method called on the sidebar of the website
public function siteSidebar()
{
$html = '<nav id="menu">';
$label = $this->getValue('label');
if (!empty($label)) {
$html .= ' <header class="major">';
$html .= ' <h2>'.$label.'</h2>';
$html .= ' </header>';
}
$html .= ' <ul>';
$staticPages = buildStaticPages();
foreach ($staticPages as $page) { //START FORAECH
$html .= '<li>';
if ($page->hasChildren()) {
$html .= '<span class="opener">';
$html .= '<a href="' . $page->permalink(FALSE) . '">' . $page->title() . '</a>';
$html .= '</span>';
}
if (!$page->hasChildren()) {
$html .= '<a href="' . $page->permalink(FALSE) . '">' . $page->title() . '</a>';
}
$html .= '</li>';
} //END FOREACH
$html .= ' </ul>';
$html .= '</nav>';
return $html;
}
}
Could you please help me to get this working ?
Thanks a lot,
TheBuzzDee