Skip to main content

Most recent suggestions?

In our case we're using the suggestion box to enable people to submit resources. I'd like to place  the 5 most recently submitted resources on the home page.

I can't seem to nail how to do this from:

http://nationbuilder.com/suggestion_page_variables

I've been successful producing the several most recent blog posts, for instance, at BaltimoreOrchard.org/home 

Here's an example of a section from that template:

<div class="padbottom padtopmore">
<div class="addreaction" style="font-size:15px; display:block"><a href="/blog"><strong>More Blog Headlines</strong></a></div>
</div>
{% for post in page.blog.most_recent_blog_posts limit:5 offset:1 %}
<div class="byline" style="margin:0 6px 0 0;">{{ post.published_at | date: '%b %d' }}</div>
<h5 class="moreblog"><a href="{{ post.url }}">{{ post.headline }}</a></h5><br />
{% endfor %}

Is there something similar to "most_recent_blog_posts" with limit and offset, available for suggestions? Does anyone have sample code to share?

Official response from

Go to your custom theme page and click New File and name it _latest_suggestions.html. Paste the following in it:

{% assign suggestions = page.suggestion_box.most_recent_suggestions %}

{% for post in suggestions limit: 5 %}
<div class="page_excerpt" id="suggestion_page_{{ post.id }}">

<h3><a href="{{ post.url }}">{{ post.headline }}</a></h3>

<div class="padtopless">
<div class="byline">
Posted by {{ post.author.published_name_linked }} &middot; {{ post.published_at | date: '%B %d, %Y %l:%M %p' }}
{% if post.show_stream? %}
{% if post.public_activities_count > 0 %}
&middot; <a href="{{ post.url }}#reactions">{{ post.public_activities_count }} reaction{% if post.public_activities_count > 1 %}s{% endif %}</a>
{% endif %}
{% endif %}
</div>
</div>

<div class="excerpt truncate-500">
{% if post.suggestion.content.size > 0 %}
{{ post.suggestion.content }}
{% else %}
<p>
{% endif %}
</div>

{% if post.suggestion.is_answered? %}
<div class="answer">
<div>
<b>
Official response from {{ post.suggestion.answer_author.published_name_linked }}
{% if post.suggestion.is_answer_type? %}
{{ post.suggestion.answer_type_html }}
{% endif %}
</b>
</div>
{% if post.suggestion.answer.size > 0 %}
<div class="answer_wrap excerpt truncate-500">{{ post.suggestion.answer }}</div>
{% endif %}
</div>
{% endif %}

{% if post.public_activities_count > 0 %}
<span class="small_button"><a href="{{ post.url }}#addreaction"><img src="{{ 'fugue-balloons' | icon_url }}" width="12" height="12" class="reaction_icon_pad" />{{ post.public_activities_count }} reaction{% if post.public_activities_count > 1 %}s{% endif %}</a></span>
{% else %}
<span class="small_button"><a href="{{ post.url }}#addreaction"><img src="{{ 'fugue-balloons' | icon_url }}" width="12" height="12" class="reaction_icon_pad" />Add your reaction</a></span>
{% endif %}


</div>

<hr />
{% endfor %}

I pulled the code above from the suggestion box template, and added limit: 5 to the for statement so it only shows 5 suggestions. Feel free to modify it further as you see fit.

Next, edit the page where you want the latest 5 suggestions to appear. Click the Template button, and add the following code where you want it to display:

{% subpage "suggestion_slug" with "latest_suggestions" %} 

Replace "suggestion_slug" with whatever the slug is for your suggestion box page.

You're done!

Share this post

Showing 3 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.