Connecting pages with tags


#1

Hi guys,

i´ve already made the following site: www.reiner-michael.de

now I´m trying to connect the articles of JOURNAL with the articles of the Homepage.
(as you can see, the tags of the articles all lead at once to the homepage)

i need to achieve the same “tag-funcionality” as on the homepage

here´s the code of one ARTICLE:

  <?php snippet('menu') ?>
  <div class="content">
    <nav role="navigation">
      <div id="menuToggle">

        <input type="checkbox" />

        <span>Tags</span>

        <ul id="menu">
            <ul>
              <li>
              <a href="<?= url($page->find('blog') . '/' . url::paramsToString(['tag' => $tag])) ?>">
                          <?= $page->tags()->html()  ?>
                        </a>
            </li>
          </ul>
          </ul>
      </div>
    </nav>
  <main class="main" role="main">
    <article class="article single wrap">
      <header class="bottomright">
        <h1><?= $page->title()->html() ?></h1>
      </header>
      <div class="bottomleft">
      </div>
<div class="vollbild">
  <div class="articlewrap">
    <?php snippet('coverimage', $page) ?>

    <div class="headline">
      <?= $page->headline()->kirbytext() ?>
    </div>
    <div class="journaltext">
      <?= $page->text()->kirbytext() ?>
    </div>
  </div>
</div>
    </article>
    <?php snippet('prevnext', ['flip' => true]) ?>
  </main>

#2

That looks strange, first of all, there are two ul elements, and then I’m missing the foreach loop that loops through the tags, outputting one tag at a time?


#3

oh right, the ul was unnecessary.

i changed it to this, but now the tags don´t show up:

  <header class="topcenter">
    <a href="<?= url() ?>" rel="home"><?= $site->title()->html() ?></a>
  </header>

  <?php snippet('menu') ?>
  <div class="content">
    <nav role="navigation">
      <div id="menuToggle">

        <input type="checkbox" />

        <span>Tags</span>
<?php $tags = $page->children()->visible()->pluck('tags', ',', true); ?>
          <ul id="menu">
            <?php foreach($tags as $tag): ?>
            <li>
              <a href="<?= url('home/' . url::paramsToString(['tag' => $tag])) ?>">
                <?= html($tag) ?>
              </a>
            </li>
            <?php endforeach ?>
          </ul>
      </div>
    </nav>
  <main class="main" role="main">
    <article class="article single wrap">
      <header class="bottomright">
        <h1><?= $page->title()->html() ?></h1>
      </header>
      <div class="bottomleft">
      </div>
<div class="vollbild">
  <div class="articlewrap">
    <?php snippet('coverimage', $page) ?>

    <div class="headline">
      <?= $page->headline()->kirbytext() ?>
    </div>
    <div class="journaltext">
      <?= $page->text()->kirbytext() ?>
    </div>
  </div>
</div>
    </article>
    <?php snippet('prevnext', ['flip' => true]) ?>
  </main>

#4

An article page doesn’t have any children, what are you trying to fetch here? The tags of all articles? Then it should be

$tags = $page->siblings()->visible()->pluck('tags', ',', true); 

#5

aah perfect, thanks! :slight_smile: