How to display full content when clicking on breadcrumbs link

Hi,

In the templates folder I’ve a seife.php file. Inside this file, I’ve the following code which works perfectly fine:

<div class="single-product">
    <div class="the-product">
 <img src="<?php echo $page->images()->first()->url(); ?>">
    </div>
    <div class="product-description">
        <ul class="breadcrumb">
      <?php foreach($site->breadcrumb() as $crumb): ?>
         <li<?php e($crumb->isActive(), ' aria-current="location"') ?>><a href="<?= $crumb->url() ?>"><?= $crumb->title()->html() ?></a></li>
      <?php endforeach; ?>    
        </ul>
        <h4><?php echo $page->name(); ?></h4>
        <h5><?php echo $page->preis(); ?></h5>
            <a class="button-two" href="/kontakt"><?php echo $page->mehr();?> </a>
        <p><?php echo $page->beschreibung(); ?>
        </p>
    </div>
</div>
</div>

In the browser, the Breadcrumbs shows: Starseite /Seife / Green Soap. When I click on Soap, I get a white page that only says “Seife”. I would like the visitor to see a list of soaps when they click on the Soap link in the breadcrumbs. How can I achieve this?

It’s like all other pages: you need to have a template which matches the name of the content file.
If you have stored all Soap pages (name: seife) under a single parent page, you need to find out about that parent page content file:

content
  |- 01_seife
    |- xxx.txt <----- what is xxx? I'll guess "seifen"
    |- 01_green-soap
      |- seife.txt

Then create a corresponding template:
seifen.php

<ul>
  <?php foreach($page->children() as $child): ?>
    <li>
       <a href="<?= $child->url() ?>"><?= $child->title()->html() ?></a>
    </li>
  <?php endforeach ?>
</ul>

Ok, let me clarify this a bit more.

In the content folder I created a folder called seife and inside this folder I created folders with different names and inside these folders that have different names I put the image of that specific soap and a soap.txt file which contains the name of that specific soap, its price and description. So, visually, the structure looks like this: content / soap/ soap-one / soap.txt + the image of the soap.

In the templates folder there is a seife.php file which shows the chair itself. This soap.php has the following code:

<ul class="breadcrumb">
      <?php foreach($site->breadcrumb() as $crumb): ?>
         <li<?php e($crumb->isActive(), ' aria-current="location"') ?>><a href="<?= $crumb->url() ?>"><?= $crumb->title()->html() ?></a></li>
      <?php endforeach; ?>    
        </ul>

which displays the breadcrumb as Starseite /Seife / Green Soap. When I click on Soap in the breadcrumb, I get a white page that only says “Seife”. I would like the visitor to see a list of soaps when they click on that Soap link in the breadcrumbs. This is what I’m trying to accomplish. I hope this clarified it better.

Perfect :slight_smile:
now create a new txt file under /content/soap, like /content/soap/soaps.txt.
Put this content into it:

Title: All your soaps are belong to us

Then create a new template as /site/templates/soaps.php:

<!DOCTYPE html>
<h1><?= $page->title()->html() ?></h1>
<ul>
  <?php foreach($page->children() as $child): ?>
    <li>
       <a href="<?= $child->url() ?>"><?= $child->title()->html() ?></a>
    </li>
  <?php endforeach ?>
</ul>
1 Like

That was great! :slight_smile: Many thanks indeed.

Hi,

Today, I applied the same pattern to another product and when I clicked on the breadcrumb link for the other product category, only a white page showed up with the name of the product. What could be the reason? Interestingly, in the previous one that we worked on, the soaps.txt file has this code under the: “Title: All your soaps are belong to us”: Uuid: dmRbH39RMIiksrVZ. This is not the case with the new txt file for the new product category I created today.