Lrx
1
Hi Kirby,
I created a page for my “notes” but the tags are not working : YAËL BENAYOUN, consultante et chercheuse indépendante
en sciences sociales
When clicking to “Numérique” or “Santé” I just have a 404 result.
Sorry for this beginner question. Can you please help me ?
Many thanks.
Your links are pointing to the blog page (https://yaelbenayoun.com/blog/tag:Numérique), when they should point to notes
.
Lrx
3
Thank you !
It works but the filter is not active. See here : YAËL BENAYOUN, consultante et chercheuse indépendante
en sciences sociales
The tag does not display the associate posts.
The php code on the /notes template is :
<h2>Exemples de productions</h2>
<p class="introbloc">
Rechercher par thèmes :
</p>
<?php
// fetch all tags
$tags = $page->children()->listed()->pluck('tags', ',', true);
?>
<ul class="taglist">
<?php foreach($tags as $tag): ?>
<p class="tags">
<a href="<?= url('notes', ['params' => ['tag' => $tag]]) ?>">
<?= html($tag) ?>
</a>
</p>
<?php endforeach ?>
</ul>
<ul class="publilist">
<?php foreach ($page->children()->listed() as $note): ?>
<li>
<a href="<?= $note->url() ?>">
<figure class="publi">
<?php if ($cover = $note->cover()): ?>
<img src="<?= $cover->crop(400, 400)->url() ?>" alt="<?= $cover->alt()->esc() ?>">
<?php endif ?>
<figcaption class="img-caption">
<?= $note->title()->esc() ?>
</figcaption>
</figure>
</a>
</li>
<?php endforeach ?>
</ul>
I don’t know how to modify my php code, do you have any clue ?
Many thanks !
I don’t see where you are filtering anything by tag? This doesn’t happen magically, please check out the docs, e.g.
Lrx
5
Hello Texnixe,
thanks for your answer as always.
I don’t know how to use php, and not sure how to use the documentation. Where do I need to add the following php filter ?
echo param('tag');
Thank you very much !
This expressions needs to be changed according to the example in the docs, i.e. conditionally, if tag is set, filter, otherwise return unfiltered.
<?php
$notes = $page->children()->listed();
if ($tag = param('tag')) {
$notes = $notes->filterBy('tag', $tag, ',');
}
foreach ($notes as $note): ?>
<?php endforeach ?>
You will need at least basic PHP skills, otherwise you won’t get very far, I’m afraid.