Forum
Creating a list of repeating posts
Hi Let's say I have a page called "acitivities.php". On that page I want to display a list of short notes (as a list). How is that best done?
I have tried this, and it's (kind of) working:
- A template page called "memberinfo.html" with this code:
<article class="message">
<h5><perch:content id="heading" type="smarttext" label="Titel" required="true" /></h5>
<perch:content id="body" type="textarea" label="text" markdown="true" editor="simplemde" size="m" required="true" />
</article>
- On the page (activites.php) I have this code:
<?php perch_content('memberinfo'); ?>
So far it seems right (?). But, on the home page I want to list the latest two activities and followed the video tutorial #14. Created another (?) template file called "_home_memberinfo.html" with the same code:
<article class="message">
<h5><perch:content id="heading" type="smarttext" label="Titel" required="true" /></h5>
<p class="date">2017-08-25
</p>
<perch:content id="body" type="textarea" label="text" markdown="true" editor="simplemde" size="m" required="true" />
</article>
(Same as "memberinfo.html")
- On the home page I have this:
<?php perch_content_custom('memberinfo', [
'page' => '/activities.php',
'template' => '_home_memberinfo.html',
'count' => 2
]); ?>
This approche have two issues: 1. The same template code in two different files 2. In the admin there is a "memberinfo" region for the Home page. I do not want that.
Is there a better way to do this? I just want one template, and let the pages display the data (and limit the count on the index page).
EDIT: Change the "template" on the Home page, get rid of issue #1, I have only one template now:
'template' => 'memberinfo.html',
Sidenote: Is there a way to display the date - when the post/entry was created - on the template? Something like this sudo code:
<?php perch:content id="DateTime" format="XXX" ?>
Best regards, Magnus
I think you are probably looking for the information on creating a list/detail page https://docs.grabaperch.com/perch/content/functions/how-do-i-create-list-detail-pages/