Page 1 of 1

How to show the current catorgy and tags for a page - php

Posted: Sat Nov 17, 2018 9:55 pm
by rduinmaijer
How can I show the current catorgy and tags for a page?

I found something like this in the docs:
<?php
$items = getCategories();

foreach ($items as $category) {
// Each category is an Category-Object
echo 'Category name: ' . $category->name();


But obviously it will show all categories and just the onces that belong to a page.

Re: How to show the current catorgy and tags for a page - php

Posted: Tue Nov 20, 2018 1:36 pm
by bayerberg
Tags

Code: Select all

if ($page->tags(true)) {
echo'<ul>';
foreach ($page->tags(true) as $tagKey=>$tagName) {
echo '<li><a href="'.DOMAIN_TAGS.$tagKey.'" rel="tag">'.$tagName.'</a></li>';
 }
echo'</ul>';
}
Categories

Code: Select all

if ($page->category()) {
 echo ' <a href="'.DOMAIN_CATEGORIES.$page->categoryKey().'">'.$page->category().'</a> ';
};