[solved] Add explanation text to categories

Post Reply
wisigerno
Jr. Bludit
Posts: 2
Joined: Fri Oct 04, 2019 5:30 pm

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
Last edited by wisigerno on Sat Oct 05, 2019 5:19 pm, edited 1 time in total.
hxii
Ssr. Bludit
Posts: 20
Joined: Sun Nov 22, 2015 11:01 am
Contact:

Categories have descriptions, would those not work?
Learn by doing.

web
wisigerno
Jr. Bludit
Posts: 2
Joined: Fri Oct 04, 2019 5:30 pm

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
Post Reply