Miva Merchant Development by Scot's Scripts

SCOTSBLOGGER: Load Posts Two Weeks Old and Display

Miva Knowledge Base
SCOTSBLOGGER: Load Posts Two Weeks Old and Display

WARNING:

This information is offered "AS IS" for internal reference only. Use at your own risk.
Does AI actually understand your Miva Merchant store? Our smart JSON-LD schema generator makes sure it does. Contact us to get started. (more info)

SCOTSBLOGGER: Load Posts Two Weeks Old and Display

Scot Ranney • November 06, 2024 (updated: November 06, 2024)


THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED;
THE AUTHOR DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR STORE DISRUPTIONS ARISING FROM ITS USE.


Display links to posts that are up to two weeks old. Change the code below for any time span you want.

This is useful for auto content on SFNT - good for SEO to have changing home page content.

1. Make sure scotsblogger page item is assigned to the SFNT or template being used for this.

2. The following code loads the posts into an array:

<mvt:comment>
#
# set up an array of posts within the last two weeks and display them above the "what module do you want" biz
# Find the blog id in the blog list
# Change 14 to whatever day span you want
#
</mvt:comment>

<mvt:assign name="g.blog_id" value="1" />
<mvt:assign name="l.days" value="14" />

<mvt:item name="scotsblogger" />

<mvt:item name="scotsblogger" param="recent posts" />
<mvt:foreach iterator="post" array="scotsblogger:posts">
	<mvt:if expr="l.settings:post:publish_t GT (s.dyn_time_t - (86400 * l.days))">
		<mvt:assign name="l.ok" value="miva_array_insert(l.settings:fposts,l.settings:post,-1)" />
	<mvt:else>
		<mvt:foreachstop />
	</mvt:if>
</mvt:foreach>

3. The following code will display the posts:

<mvt:foreach iterator="fpost" array="fposts">
	<mvt:if expr="l.pos1 EQ 1">
		<h2 class="h4 mb-3">News and Updates:</h2>
	</mvt:if>
	<p class="mb-3">
		<a class="text-decoration-none fw-bold" href="&mvt:fpost:url;">
			&mvt:fpost:title;, &mvt:fpost:updatedparsed:month_str; &mvt:fpost:updatedparsed:day;, &mvt:fpost:updatedparsed:year;
		</a>
		

		<span class="text-secondary">&mvt:fpost:synopsis;</span>
	</p>
</mvt:foreach>

https://www.scotsscripts.com/mvblog/scotsblogger-load-posts-two-weeks-old-and-display.html

mvkb_scotsblogger