Forum
Custom content with blocks
Hi,
for each page I want to output a table of contents which links to the articles on that same page.
Basically I'm following your tutorial "How do I create a FAQ?". The only difference is that the region I'm referring to contains blocks.
The problem: Instead of printing out a link for each article perch creates only an anchor tag for the first article. It has the correct href-attribute, but no anchor text.
My code looks like this:
index.php
<nav class="secondary">
<ol>
<?php perch_content_custom('Content', array('template'=>'navigation/secondary_item')); ?>
</ol>
</nav>
<main>
<?php perch_content('Content'); ?>
</main>
Content ist linked to blocks.html
<perch:blocks>
<perch:block type="article" label="Artikel">
<perch:template path="content/article.html" />
</perch:block>
<perch:block type="link_bars" label="Link-Liste (Balken)">
<perch:template path="content/link_bars.html" />
</perch:block>
<perch:block type="interview" label="Interview">
<perch:template path="content/interview.html" />
</perch:block>
</perch:blocks>
Each template within blocks.html contains
<article id="article-<perch:content id="perch_item_index" type="hidden" />">
<h4>
<div class="category">
<perch:content id="category" type="text" label="Rubrik" required="true" />
</div>
</h4>
[...]
</article>
navigation/secondary_item.html
<li>
<a href='#article-<perch:content id="perch_item_index" type="hidden" />'>
<perch:content id="category" type="text" label="Rubrik" required="true" />
</a>
</li>
secondary_item.html
needs to include a set of<perch:blocks>
tags with matching types, else it won't have any content to output.Okay.
So if I include
<perch:block type="article" label="Artikel">
it gives me links to the three articles that use that block.If I include
<perch:block type="link_bars" label="Link-Liste (Balken)">
or<perch:block type="interview" label="Interview">
it returns the links for the corresponding articles twice.Besides the doubling of the latter links: What I'm trying to get is links for all articles, no matter what block type they are.
Thanks a lot!
Right - so you need to include each block type in your link template.
Perfect! Haven't even tried it, because I thought, this would give me the links ordered by block templates.
Doubles are gone as well – for whatever reason.
Thanks so much! Jens