Forum
Filtering by a custom field in the blog app addon
Hey, I've been running in circles for a good few hours now, i'm trying to filter down results for a blog by a custom field checkbox I've added to the post.html template (The root file for blog?) I'm getting no results back, The options i'm passing to perch_blog_custom are below:
$opts = array( 'filter' => 'permissions-founding', 'match' => 'eq', 'value' => 1, 'sort' => 'postDateTime', 'sort-order' => 'DESC', 'template' => 'blog/post_in_list.html' );
I can confirm there are multiple posts that have the permissions-founding set to 1 and if i use the permissions-founding tag within any template it outputs just fine. My hair's started to go grey, any ideas how I can achieve this?
Many Thanks,
You need to add your field to the
post.html
template so that the data is stored with the post. Adding it to the post page itself won't work.Sorry my apologies, I meant I've added the field to the post.html file.
So I've added the following tags to the end of the post.html file:
<perch:blog id="permissions-founding" type="checkbox" label="Founding Member" divider-before="PERMISSIONS" /> <perch:blog id="permissions-other" type="checkbox" label="Other Member" divider-after="Meta information" />
The checkboxes need a value, e.g.
value="1"
Also, you have dashes in your IDs, which would be worth correcting.