Skip to content
Snippets Groups Projects
Commit 74e7d68a authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: add category_label component to include parent category in about podcast page

parent e2e73581
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ declare(strict_types=1); ...@@ -7,6 +7,8 @@ declare(strict_types=1);
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3 * @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/ * @link https://castopod.org/
*/ */
use App\Entities\Category;
use App\Entities\Location; use App\Entities\Location;
use CodeIgniter\I18n\Time; use CodeIgniter\I18n\Time;
use CodeIgniter\View\Table; use CodeIgniter\View\Table;
...@@ -331,3 +333,18 @@ if (! function_exists('explicit_badge')) { ...@@ -331,3 +333,18 @@ if (! function_exists('explicit_badge')) {
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
if (! function_exists('category_label')) {
function category_label(Category $category): string
{
$categoryLabel = '';
if ($category->parent_id !== null) {
$categoryLabel .= lang('Podcast.category_options.' . $category->parent->code) . ' › ';
}
return $categoryLabel . lang('Podcast.category_options.' . $category->code);
}
}
// ------------------------------------------------------------------------
...@@ -23,7 +23,7 @@ if (! function_exists('get_podcast_metatags')) { ...@@ -23,7 +23,7 @@ if (! function_exists('get_podcast_metatags')) {
{ {
$category = ''; $category = '';
if ($podcast->category->parent_id !== null) { if ($podcast->category->parent_id !== null) {
$category .= $podcast->category->parent->apple_category . ' > '; $category .= $podcast->category->parent->apple_category . ' ';
} }
$category .= $podcast->category->apple_category; $category .= $podcast->category->apple_category;
......
...@@ -37,7 +37,7 @@ class PodcastActor extends ActorObject ...@@ -37,7 +37,7 @@ class PodcastActor extends ActorObject
$category = ''; $category = '';
if ($podcast->category->parent_id !== null) { if ($podcast->category->parent_id !== null) {
$category .= $podcast->category->parent->apple_category . ' > '; $category .= $podcast->category->parent->apple_category . ' ';
} }
$category .= $podcast->category->apple_category; $category .= $podcast->category->apple_category;
......
...@@ -6,15 +6,11 @@ ...@@ -6,15 +6,11 @@
<div class="mb-2"><?= $podcast->description_html ?></div> <div class="mb-2"><?= $podcast->description_html ?></div>
<div class="flex gap-x-4 gap-y-2"> <div class="flex gap-x-4 gap-y-2">
<span class="px-2 py-1 text-sm font-semibold border rounded-sm border-subtle bg-highlight"> <span class="px-2 py-1 text-sm font-semibold border rounded-sm border-subtle bg-highlight">
<?= lang( <?= category_label($podcast->category) ?>
'Podcast.category_options.' . $podcast->category->code,
) ?>
</span> </span>
<?php foreach ($podcast->other_categories as $other_category): ?> <?php foreach ($podcast->other_categories as $other_category): ?>
<span class="px-2 py-1 text-sm font-semibold border rounded-sm border-subtle bg-highlight"> <span class="px-2 py-1 text-sm font-semibold border rounded-sm border-subtle bg-highlight">
<?= lang( <?= category_label($other_category) ?>
'Podcast.category_options.' . $other_category->code,
) ?>
</span> </span>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment