Invision Community 5: A video walkthrough creating a custom theme and homepage By Matt Thursday at 04:02 PM
AlexWright Posted May 9, 2020 Posted May 9, 2020 Hi all! We'd like to add the Grid View of recent "Blog" entries as a placeable Pages block. Was hoping the following would work, but all I'm getting is "No Story Entries Yet" (We've renamed the module Stories, and use it for user-written Literature). Any help would be amazing, thanks! We're on the latest 4.4.10. {expression="\IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'story'))"} <section class='ipsType_normal ipsSpacer_both cBlog_grid' data-controller='blog.front.browse.grid'> {{if \count($entries)}} {{$count = 0;}} {{if $pagination['page'] == 1}} <div class='cBlog_grid_row cBlog_grid_row--primary'> {{foreach $entries as $id => $entry}} {{if $count == 2}} {{break;}} {{endif}} {template="indexGridEntry" app="blog" location="front" group="browse" params="$entry, true"} {{$count++;}} {{endforeach}} </div> {{endif}} {{$count = 1;}} {{$subcount = 0;}} <div class='cBlog_grid_row'> {{foreach $entries as $id => $entry}} {{$subcount++;}} {{if ( $pagination['page'] == 1 and $subcount > 2 ) or ( $pagination['page'] > 1 and $subcount)}} {template="indexGridEntry" app="blog" location="front" group="browse" params="$entry"} {{if $count % 3 == 0}} </div> <div class='cBlog_grid_row'> {{endif}} {{$count++;}} {{endif}} {{endforeach}} </div> {{else}} <div class="ipsBox ipsType_center ipsPad"> <p class="ipsType_large">{lang="no_entries_yet"}</p> </div> {{endif}}
Sonya* Posted May 10, 2020 Posted May 10, 2020 (edited) This {{if \count($entries)}} returns NULL or 0. Try this: {{if !empty( $entries ) }} I have difficulties with count in the template. The variables seem to be not numeric (countable) so that count does not always work. Edited May 10, 2020 by Sonya* AlexWright and Meddysong 2
AlexWright Posted May 13, 2020 Author Posted May 13, 2020 On 5/10/2020 at 5:08 AM, Sonya* said: This {{if \count($entries)}} returns NULL or 0. Try this: {{if !empty( $entries ) }} I have difficulties with count in the template. The variables seem to be not numeric (countable) so that count does not always work. Unfortunately didn't work. I also tried changing the following $count = 0 to $entries = 0, with no luck there either.
opentype Posted May 13, 2020 Posted May 13, 2020 5 hours ago, AlexWright said: I also tried changing the following $count = 0 to $entries = 0, with no luck there either. That would essentially delete your blog entries. Sonya provided the correct code to check for entries. But that has nothing to do with your internal counter. I would always start with IPS’ block template and modify it step by step, instead of taking code from somewhere else that probably doesn’t work in a block. I see other problems too, like that $pagination variable, which should also fail in a block. AlexWright 1
Recommended Posts