Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: smd_featured: Quickly pull articles to your home / landing pages
Thanks for the update, Stef. I was just about to try something like John Stephens did. And now I won’t be confumbulated when it doesn’t work, because… of course now it will work!
I love this plugin! My entire front page runs from it. You truly are the Prince of Blokes!;)
— Bob
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Dare I ask????
Stef, one thing that would make this plugin even cooler than a Mint Julep would be some kind of date control override.
For example… I’d like to set my Featured Articles up to be selected at random by the plugin, EXCEPT during one specific time span. During that time span (Christmas day, for instance), I’d like to feature only one specific Featured Article that’s specific to the time span (to continue this example, it might say “Merry Christmas”), instead of the usual order of randomness that would occur outside of that particular time span.
The above description may sound complicated, but the effect could probably be accomplished with some sort of a date flag that could be attached to the plugin (on the “Edit” screen) which automatically triggers it into “Posted desc” mode instead of “rand()” on a given date. Then it would select the most recent article from the database. And when writing that particular article I would set the Publish date to whatever target date I want the the plugin to start showing it.
Then the “Trigger Date” would pop the Plugin out of “rand()” selection mode into “Posted desc” selection mode and the specific article I want featured would be the only choice for “Posted desc” until it expires according to whatever Expire Date I set in the Article Write tab. At which time the plugin could (though it wouldn’t have to) revert back to “rand()” selection.
Is this making sense? Is it feasible? Or is it beyond the scope of what a single plugin could accomplish? Or could I accomplish the same thing by combining SMD_Featured with SMD_If? Or am I completely whacko and should stop smoking whatever it is I’m smoking?
Just asking!;) Feel free to call me nuts (or anything else), but I had to ask.
Thanks again for a wonderful plugin!
Last edited by bg (2010-10-08 03:11:34)
— Bob
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Dohhhh…. slap me upside the head with a wet tortilla, please!
Must’ve been noodling this around in my sleep because I woke up this morning realizing it could be accomplished simply by setting up two different TXP Forms, one for Posted desc and one for rand() selection; then using a simple PHP date script to call the appropriate form.
That would allow me to make it completely automatic (and idiot proof for those who contribute to the site) — a definite plus.
Now I’m embarrassed for wasting bandwidth with the question! Too many hours staring at the screen, maybe?
But thanks for reading, any way;)
— Bob
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
bg
You’re right that date-based article selection is probably outside the scope of this plugin. Glad you figured it out in the end, though. Having a few forms is a good way to manage it. I’m sure there’s a generic date plugin out there somewhere (I think Rick Silletti has one? ras_if_date or something?) But a jot of PHP will do the job as you found.
Incidentally, in addition to the slightly awkward smd_calendar (still in need of a rewrite) I had a stab at a sort of date-ish plugin for counting down to specific events, unsurprisingly called smd_countdown. So if you wanted to pimp your featured articles in advance or tease people with what’s to come you may be able to use that plugin or smd_horizon in conjunction with smd_featured. Never tried it, but it might work.
Failing all that, smd_if is perhaps a reasonable alternative. Not sure how it’d work off the top of my head, but it’ll probably be able to manage it if you can get at the relevant variables, though my guess is the raw PHP will be more efficient (depending on what you want to do with it all).
Last edited by Bloke (2010-10-08 16:33:54)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Yo Bloke!
Thanks for your thoughts, Stef…
Yeah, I think the raw PHP and a couple of forms will be more efficient. And certainly a lot simpler that trying to figure out (and test) how all those plugins will work together. Before I switched the site in question to Textpattern I was using a PHP include to insert specific date text in certain pages that required it. I think just modifying that include to insert text for a TXP Form instead of the date text will do the trick.
Nice thing about that solution is I can set it up once and it’ll be automagic forever after.
Thanks again for your reply!
— Bob
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Maintenance release v0.31 is out. No new functionality, but it looks a helluva lot better on admin themes other than classic. Many thanks to Stuart (thebombsite) for refactoring the style rules for me.
Also rejigged the plugin help styling to remove most of the colour information, allowing the theme’s colour scheme to take over.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Another update to v0.32. Features:
- Added ability to page through
<txp:smd_unfeatured />
result sets if there’s no other paging on the current page - Added
section
,status
andtime
filtering to smd_unfeatured - Fixed some styling errors
This now allows you to pull some featured articles out of your flow and then treat the remaining articles exactly as you would if you used an article tag, except the featured articles are not in the paged results. Paging is not automatic, though — you need to enable it by specifying pageby
. The docs reveal more.
Hope this version helps someone.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Stef, Great plug-in. Exactly what I needed! I will donate to the cause today.
I have a problem with getting one of your scripts to work. Using the following example script, how do I get the “featured” version to show the full article and not the excerpt of it. (I tried to simply eliminate the “<txp:excerpt>” tag but that made the article disappear.
Here’s the script:
<txp:smd_featured label=“feature” wraptag=“div” html_id=“main_feature”> <txp:permlink><txp:title /></txp:permlink> <txp:article_image class=“feat_image” /> <p class=“leadin”><txp:excerpt /></p>
</txp:smd_featured>
<hr /> <h3>Recent Articles </h3> <txp:smd_unfeatured section=“articles” wraptag=“div” html_id=“main_feature”> <txp:permlink><txp:title /></txp:permlink> <txp:article_image class=“feat_image” /> <p class=“leadin”><txp:excerpt /></p> </txp:smd_unfeatured>
Marcus, you suggested that I look the limit and offset txp:article attributes and use two different forms. I can’t picture what you mean by this.
Also, I’d like to know HOW TO LIMIT THE AMOUNT OF LINE TEXT VIEWABLE (like excerpt, but be able to control the exact amount of lines).
THANKS AGAIN!
Last edited by laptophobo (2010-12-02 04:39:36)
Living the Location-Independent Life: www.NuNomad.com
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Hi, Stef!
I think I found a regression in the new version of the plugin. When I installed it, I got the pre v0.30 behavior again. Rolling back to v0.30 fixed the problem.
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
Hi Bloke:
Quote from help docs:
Each time you use <txp:smd_featured /> it makes a note of the articles it has displayed and will not duplicate articles in later tags.
Please, could you consider adding the option to disable this feature? If so, I wonder what would be better: a site-wide option (mmm, not ideal) or a per-tag/per-label (mmmm, seems a good option) basis option.
Let me explain why I’d like to turn off this feature.
There are some commonly used UI widgets, like tabs, that usually requires two separate components made from the same “raw material”. On a system like TXP, one way to solve this is iterating twice over the same list of articles, generating each component with the proper markup.
Two identical txp:article_custom
tags usually do the job.
But its cousin, txp:smd_featured
, won’t, as per the help doc says, it won’t ever repeat the same featured article.
A workaround to this is to first fetch the article ids using txp:smd_featured
and them feed them to txp:article_custom
on id
attribute.
Like this:
<txp:variable name="featured_home_ids"><txp:smd_featured label="featured_home" limit="5" break=","><txp:article_id /></txp:smd_featured></txp:variable>
<txp:article_custom id='<txp:variable name="featured_home_ids" />' limit="5" wraptag="ul" class="slidetabs">
... slide tabs...
</txp:article_custom>
<txp:article_custom id='<txp:variable name="featured_home_ids" />' limit="5" wraptag="ul" class="slidepanes">
... slide panes ...
</txp:article_custom>
This works, but it has one drawback: I cannot use txp:smd_featured_info
(thus, no access to the Title and Description for featured articles) within article_custom. I could also workaround this drawback by creating some unique variables, like a pseudo array, on the fly, like <txp:variable name='title_<txp:article_id />'><txp:smd_featured_info type="title" /></txp:variable>
. I may go down that path, but I consider it a hassle.
Another workaround to this, that I’ll also consider as it’s a nice/basic JS exercise to practice, is to generate just one of the widget components, and create the other one just using JS on the client-side. That method may have some advantages too…
So, back to the feature request, I think there could be an attribute that disables the if (!empty($smd_prior_featured)) {...}
(which is how I currently handle this, by commenting out that code). It may even be on a per-label basis. Right now I can’t think how the attribute could be named and what would be the possible values, but as a first approach, I’m thinking about a flush_prior
attribute, and values like: 0
(don’t flush) 1
(flush, thus, include featured articles already listed by other smd_feature tag).
Thanks for reading!
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
maniqui
Piece of cake, though I should probably add it to smd_unfeatured too. Until I can get round to doing it officially…
To line 690ish, add:
'history' => '1',
Then alter the block at line 715 to read:
if ($history && !empty($smd_prior_featured)) {
$where .= ' AND smdfeat.feat_id NOT IN(' . join(',', $smd_prior_featured) . ')';
}
And finally add this around line 764 (in the ‘unset’ block) :
$atts['history'],
Job done. history="0"
makes the history, erm, history!
Last edited by Bloke (2010-12-11 15:46:03)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_featured: Quickly pull articles to your home / landing pages
v0.33 is out. Features and fixes:
- New
history
attribute to both<txp:smd_featured />
and<txp:smd_unfeatured />
so you can decide if the tags interact with each other or not (thanks maniqui) - Bug fix for my silly v0.32 regression that johnstephens spotted (thanks)
- Bug fix so that smd_unfeatured won’t default to displaying txp:article’s default 10 articles if there are no matches (or all your unfeatured articles have already been featured)
As always, let me know if you have any problems or success stories with this plugin.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline