Skip to content

Instantly share code, notes, and snippets.

@joeworkman
Last active November 16, 2018 23:27
Show Gist options
  • Save joeworkman/876b43535b3c1f9db055e824d7b92289 to your computer and use it in GitHub Desktop.
Save joeworkman/876b43535b3c1f9db055e824d7b92289 to your computer and use it in GitHub Desktop.
This will create menu items for every category in a Total CMS blog. You can place this snippet in any Foundation menu stack that supports custom HTML menus
<li class='has-dropdown'><a href='#'>Categories</a><ul class='dropdown'>
<?php
$cmsid = "blog";
$attribute = "category"; // tag, category, author
$href = "/blog/?category="; // URL to blog list with category filter
//-----------------------------------------------
// Do not modify below this line
//-----------------------------------------------
if ($publish) {
$totalblog = new \TotalCMS\Component\Blog($cmsid);
$attrs = $totalblog->list_attributes($attribute);
foreach ($attrs as $attr) {
$perm = explode("=",$attr["params"])[1];
$label = $attr["label"];
echo "<li><a href='$href$perm'>$label</a></li>";
}
}
?>
</ul></li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment