Hello, I have a question about putting tags on the routed url.
It means I re-routed the url without ‘home/’.
ex) home/text → /text
And then, after I put tags on the page called ‘home/texts/text’, I can see titles of tags but when I click it, the url goes to error page. So that I couldn’t see that the text list is categorized by tags.
Do you know how can I edit these code for this issue?
Thank you:)
on config.php
c::set('routes', array(
array(
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if(!$page) $page = page('home/' . $uid);
if(!$page) $page = page('home/press/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
),
array(
'pattern' => ['home/(:any)', 'home/press/(:any)'],
'action' => function($uid) {
go($uid);
}
)
));
on controllers/text/php
<?php
return function ($page) {
$textcategory = param('textCategory');
$textslist = page('home/press/texts')->children()->listed();
$textcategories = $textslist->pluck('textCategory', ',', true);
$textslist = $textslist
->when($textcategory, function ($textcategory) {
return $this->filterBy('category', $textcategory, ',');
});
return compact('textslist', 'textcategories');
};
on text.php
<ul class="filter--category">
<?php foreach ($textcategories as $textcategories): ?>
<li>
<a href="<?= $page->parent()->url(['params' => ['textCategory' => $textcategories]]) ?>"><?= html($textcategories) ?></a>
</li>
<?php endforeach ?>
</ul>