Page 1 of 1

[solved] Add explanation text to categories

Posted: Fri Oct 04, 2019 5:39 pm
by wisigerno
Hi everyone,

I have a client who wishes to add some explanatory remarks to his categories. I envision this to be solved with bootstrap (like this https://getbootstrap.com/docs/4.0/compo ... on-example).

The following example should clarify what I mean:

+ General
- Music
What music I like and why …
+ Paintings

Can this be done and how?

Thanks in advance,
wisigerno

Re: Add explanation text to categories

Posted: Fri Oct 04, 2019 11:50 pm
by hxii
Categories have descriptions, would those not work?

Re: Add explanation text to categories

Posted: Sat Oct 05, 2019 5:18 pm
by wisigerno
In fact, they do. I was able to do something like this:

Code: Select all

<?php
$items = getCategories();
foreach ($items as $category) {
if (count($category->pages())>0) {
echo '<button class="btn btn-light btn-lg btn-block mb-3 text-left" data-toggle="collapse" href="#' . $category->key() . '" role="button" aria-expanded="false" aria-controls="' . $category->name() . '"><a class="text-info card-link" href="' . $category->permalink() . '">' . $category->name() . '</a><span class="text-info collapse-open"> +</span></button>
<div class="collapse" id="' . $category->key() . '">
<div class="card card-body">
<small>' . $category->description() . '</small>
</div>
</div>';
}
}
?>
This works like a charm!

Have a nice evening,
wisigerno