Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-08-22 07:26:07

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Homepage article logic

I am working on a big redesign/overhaul of my website here, and it’s coming along nicely. Wanted to share though the logic that drives what articles are on the homepage, based on custom fields, sections, expiration times, etc. This is mostly a testament to the ridiculously helpful folks in the forum, particularly colak and etc:

<!-- Initialize database magic -->
<txp:php>safe_query("SET @ord1='High', @ord2='Medium', @ord3='Low'");</txp:php>

<!-- Gather featured future Events,fundraisers,Films,performing-arts -->
<txp:variable name="featured-events" value='<txp:article_custom time="future" Featured="_%" section="Events,fundraisers,Films,performing-arts" break=","><txp:article_id /></txp:article_custom>'/>

<!-- Gather featured articles regardless of date: about,Distance-Learning,education-listing,Item -->
<txp:variable name="featured-non-events" value='<txp:article_custom time="any" Featured="_%" section="about,Distance-Learning,education-listing,Item" break=","><txp:article_id /></txp:article_custom>'/>

<!-- Grab one blog post - "Featured" used only to sort -->
<txp:variable name="blog" value='<txp:article_custom time="past"  section="blog" limit="1" ><txp:article_id /></txp:article_custom>'/>

<!-- Grab one future exhibition -->
<txp:variable name="future-exhibition" value='<txp:article_custom time="future" section="visual-arts" sort="Posted asc" limit="1"><txp:article_id /></txp:article_custom>'/>

<!-- Grab one current exhibition -->
<txp:variable name="current-exhibition" value='<txp:article_custom time="past" expired="0" section="visual-arts" sort="Posted desc" limit="1"><txp:article_id /></txp:article_custom>'/>

<!-- Combine all the gathered stuff and output -->
<txp:article_custom id='<txp:variable name="featured-events"/>,<txp:variable name="featured-non-events"/>,<txp:variable name="blog"/>,<txp:variable name="future-exhibition"/>,<txp:variable name="current-exhibition"/>' time="any" form="2014-homepage-mega-featured" limit="99" sort="FIELD(custom_12, @ord1, @ord2, @ord3), Posted desc" limit="1" />

<txp:article_custom id='<txp:variable name="featured-events"/>,<txp:variable name="featured-non-events"/>,<txp:variable name="blog"/>,<txp:variable name="future-exhibition"/>,<txp:variable name="current-exhibition"/>' time="any" form="2014-homepage-featured" limit="99" sort="FIELD(custom_12, @ord1, @ord2, @ord3), Posted desc" limit="10" offset="1" />

Yes, I have tried turning it off and on.

Offline

#2 2014-08-22 15:16:54

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Homepage article logic

Nice site!

You have limit set twice in each article_custom tag.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2014-08-22 20:44:57

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Re: Homepage article logic

MattD wrote #283158:

You have limit set twice in each article_custom tag.

OH, good catch, thanks. TXP must be taking the last one in that case, ‘cause the behavior was what I was expecting.


Yes, I have tried turning it off and on.

Offline

Board footer

Powered by FluxBB