Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-06-17 23:04:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

smd_featured: Quickly pull articles to your home / landing pages

Ever wanted to just ‘feature’ an article or 4 on your home page but still leave it in the article flow for later? Messing around with the Sticky status means complications with extra article tags. Wasting a custom field to mark articles as ‘featured’ seems heavy handed and means you have to train your users to a) put them in, b) find them and remove them when you need to rotate the home page articles.

Lucikly, you can download smd_featured — your one-stop shop for all things featury.

Visit the Content->Featured articles tab and you’ll see a grid of all your articles. Click one. Job done. It’s now tagged as ‘featured’ and you can use the <txp:smd_featured /> tag to display it wherever you like in your Page template.

Click some more articles. Go nuts. They’ll all be displayed by the tag. If you want to unfeature an article, click its name again and confirm. That’s it.

Except it isn’t of course, because this is an smd plugin :-)

When you feature an article you can click the [Edit] button next to it and optionally assign a label, along with some titla and description text (Textiled if you prefer). This info is displayable alongside other article tags when you lay your featured blocks out. So you could use the description as lead-in text to entice the reader to click the link and reserve your excerpt/body/custom fields for regular purposes. The label is a great way to group your articles into, say, ‘featured’ or ‘teaser’ groups and pull them out separately. And when you display your articles, the plugin keeps track of which ones you’ve shown so it doesn’t duplicate them later.

On the admin side, with large numbers of articles it can become difficult to find stuff so there’s a search facility and a dropdown so you can filter the list by label. You can find out more in the help of course. (smd_prefalizer can help you make any hidden prefs you may like to employ).

Works best on TXP 4.3.0 but will work(ish) on 4.20. I hope this proves useful. Share and Enjoy™.

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.

  • 18 Jun 2010 | 0.10 | Initial release
  • 07 Sep 2010 | 0.20 | Renamed id column to feat_id ; fixed label attribute bug (both thanks pieman) ; label searches are now exact matches ; added prefs and pagination support for admin side ; added <txp:smd_if_featured> ; added label selection from dropdown during editing (thanks tye)
  • 13 Sep 2010 | 0.21 | Added ‘title’ and Textile options (both thanks bg)
  • 13 Sep 2010 | 0.22 | Fixed missing doSlash() on untextiled html content (thanks bg)
  • 05 Oct 2010 | 0.30 | Use article_custom() not article() to sidestep individual article context (thanks johnstephens) ; pass time and limit to article_custom() ; limit has default of 10
  • 11 Oct 2010 | 0.31 | Better theme integration (thanks thebombsite)
  • 01 Nov 2010 | 0.32 | Added older/newer pagination support to <txp:smd_unfeatured /> and permitted section, status and time filtering ; fixed some styling issues
  • 17 Jan 2011 | 0.33 | Added history attribute (thanks maniqui) ; fixed smd_unfeatured to work correctly in individual article context after the v0.32 regression (thanks johnstephens) ; fixed smd_unfeatured bug to stop txp:article’s default output if unfeatured list empty
  • 17 Jan 2011 | 0.34 | Added txp:else support to featured / unfeatured tags
  • 12 May 2011 | 0.40 | Added positional sorting, allowed label/title/desc to be optional, removed ‘Are You Sure’ message if label/title/desc not used, and added full Write tab edit links (all thanks pieman) ; added hidden prefs to interface ; made textile prefs global (previous settings will be lost on upgrade) ; global prefs only editable by publisher ; <txp:smd_featured /> default sort order now feat_position asc, Posted desc
  • 02 Dec 2011 | 0.41 | Allowed section_list in the admin page’s URL to limit the list of featured articles to the given section(s) (thanks mickmelon) ; fixed trim on label attribute (thanks maniqui)

Last edited by Bloke (2011-12-02 13:40:35)


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

#2 2010-06-17 23:47:31

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

Proof that you are truly a machine. Gonna check this now…

Offline

#3 2010-06-18 00:50:56

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

I was just cursing this today… curious to try it out. Thanks!


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#4 2010-06-18 01:47:18

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

I think someone had better write a <txp:smd_sleep /> plugin for Stef!

Offline

#5 2010-06-18 15:37:55

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: smd_featured: Quickly pull articles to your home / landing pages

aslsw66 wrote:

I think someone had better write a <txp:smd_sleep /> plugin for Stef!

:D But don’t forget the <txp:smd_wakeup /> for when we need him ;)

Offline

#6 2010-06-18 15:44:15

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

Let’s add also <txp:smd_feature_request />, for when we (and I’m certainly part of the “we”) need Stef to add that feature that he forgot (how could he, when his plugins have more features than a swiss army knife made of tiny swiss army knifes?) to add on any of its plugins.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2010-06-18 18:56:00

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: smd_featured: Quickly pull articles to your home / landing pages

Please don’t forget the <txp:smd_saved_my_as%$%_again/>, for all of those times you needed a plugin —- thought there was not one and then in a last ditch search discovered Stef had one or even better yet looked at one of Stef’s prolugins — needed it tweaked for your project — and the master delivered —-

Thanks Stef.

Offline

#8 2010-06-19 00:21:10

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: smd_featured: Quickly pull articles to your home / landing pages

<txp:smd_we_love_stef />. And I’m serious :)

Offline

#9 2010-06-21 19:36:21

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

Feckin ace. Something like this has been on my wishlist for a long time.

And <TXP:SMD_UNFEATURED /> is the icing on the cake.

Offline

#10 2010-06-21 20:34:29

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

Stef, I’m kicking it around and among all the overall brilliance I found a few unexpected behaviours…

In Mac / Safari Version 4.0.4 (5531.21.10), selecting a label in the Article live search filter wonks the page out.

“Safari is no longer responding because of a script on the webpage ‘Txp › Stuart Charlton › Featured articles’ (http://local.stuartcharlton.com/textpattern/index.php). Do you want to stop running the script, or let it continue?”

Similar effects in Chrome (although if you choose to “wait” for the script it kicks in eventually). No such problems in Mac / Firefox 3.5.9

If no featured articles are labelled, and if the label attr is unset, both featured and not-featured articles are displayed. I suppose this is an unlikely use case, but if you didn’t need multiple types of featured articles it would be easier not to bother with labeling for categorisation (although you might want to use the label field simply for output with <TXP:SMD_FEATURED_INFO />).

I get an error when trying sort="id"

Tag error: <txp:smd_featured wraptag="dl" limit="10" sort="id"> -> Textpattern Warning: Column 'id' in order clause is ambiguous SELECT *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod FROM textpattern AS txp LEFT JOIN smd_featured AS smdfeat ON txp.ID=smdfeat.id WHERE 1=1 AND Posted <= now() AND Status in (4,5) ORDER BY id LIMIT 10 on line 85

There doesn’t seem to be a default value for limit – when unset I thought it would spew 10 like txp:article but I get the full whack

Offline

#11 2010-06-21 22:08:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_featured: Quickly pull articles to your home / landing pages

pieman wrote:

I’m kicking it around and among all the overall brilliance I found a few unexpected behaviours…

Thought you’d like it: wrote it with you in mind :-)

Thanks for the reports. Let’s dive in and figure out the unexpectedness…

In Mac / Safari Version 4.0.4 (5531.21.10), selecting a label in the Article live search filter wonks the page out.

I’ll check this out if I can find a Mac lying around. How many articles are we talking about here on your site? I only tested up to about 700 or so in Firefox and it worked ok — if a tiny but slower than I’d liked. After reviewing things the last couple of days I think it may be prudent to offer the option of ditching the live search in favour of a traditional search for those sites with masses of articles. If I can figure something out I’ll do it. That does probably mean I’ll have to bite the bullet and get rid of all the hidden prefs nonsense and make a proper prefs screen, which takes a bit longer…

Similar effects in Chrome

That does surprise me because I thought Chrome was supposed to have the fastest javascript engine around. I’ll give it a grilling. Perhaps the non-live search will help things.

If no featured articles are labelled, and if the label attr is unset, both featured and not-featured articles are displayed.

Yes, it essentially defaults to being an article tag. I decided (for whatever reason) that in a mixed labelled/non-labelled environment that you should explicitly state your intention to display the unlabelled ones by using label="". Otherwise you’d see all featured (labelled + non-labelled) articles. This made sense to me when I wrote it; perhaps wrongly.

But I don’t think I tried it with no labels set at all, which may trigger this obscure bug. Like you, I would expect without any attributes the plugin to display just the featured articles, so I need to figure out a way of doing:

If no label attribute is given AND there are no labels set at all against any article, treat <txp:smd:featured /> as if you’d typed <txp:smd_featured label="" />, otherwise treat the label attribute as set by the tag.

Didn’t fancy explaining that dual use of the label attribute in the docs so I went with the simpler “Thou must always state thine intentions” approach. If I can think of a way round this that simplifies it / makes it more intuitive (or you can?!) I’ll see what can be done.

I get an error when trying sort="id"

Knew my laziness would bite me. I stupidly named the column in the smd_featured table id to make the querying shorter but when doing a “SELECT *” it means there are two ‘id’ columns in the results. Perhaps I’ll change my id column to feat_id or something to avoid the clash. Won’t affect the ability to sort by ID because it’ll pick up the one from the textpattern table. For now — as a workaround — try sort="txp.id" and see if that fixes it.

There doesn’t seem to be a default value for limit

No, I left it up to you. I figured most people wouldn’t even reach 10 featured articles of one type on the front page of any site — maybe one or two at a push, or perhaps eight teasers or something. Suppose there’s no harm in supplying a maximum of 10 by default. But then — on the flipside — there’s no pagination support for featured articles so limit doesn’t really work the same way as it does in articles: it’s a true hard limit.

Dunno, I’m kind of torn with this one. If you can convince me that a limit of 10 by default is not going to have swathes of people knocking on my door asking why there are only 10 featured articles output with no way of seeing the others, I’ll do it ;-)

Cheers for the reports. I’ll tend to this little lot when I get a moment. Also going to try and add <txp:smd_if_featured> (with optional label attribute) which you can use inside any article context. Watch this space.


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

#12 2010-08-19 15:54:29

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: smd_featured: Quickly pull articles to your home / landing pages

Hey Bloke,
I’m probably doing something very wrong, but
<txp:smd_featured form=“home_listing” limit=“3”/>

is producing a list with 3 non-featured articles, even though I have already selected some on the admin page…

any clues??


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

Board footer

Powered by FluxBB