8

I'd like to implement something similar to "sticky" articles in a forum, where one or two of these appear at the top, followed by blog content, and I want these "sticky" articles to be editable by a moderator in the front-end.

One way of simulating a single "sticky" article is to place the content in the category description, but, this only works for one article, and it not editable in the front-end.

I'm willing to think laterally. Perhaps I'm thinking about it all wrong. This could possibly be done as a separate blog category that is displayed below the main articles (in a module?), and where the blog items themselves are managed under a separate menu item.

9

The simplest method that I can think is to use the "featured" option on the articles. Mark any article that you want "sticky" as "featured" in the article manager.

Then on the menu item for the blog layout, switch to the "blog layout" and look for "article order". Select "Featured Articles Order" to put the featured articles first.

The bad side of this method is that it uses "ordering" as the secondary metric instead of date. So the articles will put the featured first and then sort them by the ordering that you set in the article manager, not necessarily newest first. (This allows you to order the sticky articles though, so that is nice.)

I believe that new articles will default to the top order spot, so it should be roughly in date order, but there could be some quirks to that.

[ PW: The secondary ordering is the feature order, not the article order, hence that's problem, unless I modify core code to add a third ordering. I've created Joomla Tracker Item #33685 and included a patch. Now all we need to do is get it tested and accepted. ]

  • Great answer, I'd never though of using Featured Articles Order like that. It "almost" works too, however the sub-ordering is strange. I have 1 existing, featured article (A), displayed in a category blog. I create two new articles, B and C. These appear as A, B, C, despite the article order being C, B, A (i.e. new ones first). When I flag B as featured, it appears above A. I'm using 2.5.19. I'll need to check some code to confirm the ordering - perhaps there's no sub-ordering in 2.5, and it's just random. – Peter Wiseman May 1 '14 at 3:15
  • Yeah, I have not actually tried to do this, but I feel like there is a solution within this. Manually ordering would be a HUGE pain though... – David Fritsch May 1 '14 at 3:19
  • The sub-ordering uses only the feature order, not the article order. :( components/com_content/helpers/query.php:orderbySecondary – Peter Wiseman May 1 '14 at 3:44
  • 1
    I've created a Joomla Tracker Item which includes a patch, adding a tertiary order to the Featured Articles Order. joomlacode.org/gf/project/joomla/tracker/… – Peter Wiseman May 1 '14 at 23:12
  • 1
    Yes, that patch fixes it for me. The non-featured articles have NULLs for fp.ordering. The FP table is an outer join which is only populated for featured articles. – Peter Wiseman May 1 '14 at 23:34
7

Matt Thomas recently described his method, which I also favour, for creating sticky articles in Joomla 3.x:

http://betweenbrain.com/notes/71-sticky-articles-in-joomla-3

In essence all you need to do is order articles by created date and set the creation date on your ‘sticky’ article to something far in the future.

  • Whilst it's the best answer so far, it's still not ideal. I had wanted to sort by the modified date, but that's not user changeable. The published date would make more logical sense than the created date for the order of the non-sticky items, but then the sticky articles would be published so far in the future, they would never appear. So I guess the created date will have to do. Or... I could hack the core code after every update (not a pleasant prospect). – Peter Wiseman May 1 '14 at 22:10
  • Well, that's the other option for sure. But rather than hack core you could simply use a template override of com_content/category/default.php and hardcode in the ‘sticky‘ article by referencing its ID directly. I'd suggest simply inserting a new section above the lead articles section to contain that. – Seth Warburton May 2 '14 at 7:35
  • Something like this? In blog.php. Is there a better way to get an article? This is simply a fixed article which will apply to all category blogs. I want the "sticky" articles corresponding to the category. <div class="items-sticky"> <?php $stickymodel = JModelLegacy::getInstance('Article', 'ContentModel'); $this->item = $stickymodel->getItem(142); echo $this->loadTemplate('item'); ?> </div> – Peter Wiseman May 3 '14 at 14:17
1

I'm not exactly sure about this,

Set the order in the article manager. There you can set the order to a negative value (e.g. -10). This way the article will stay on top. I think it somehow depends on the setting in your menu (advanced setting of the way the articles must be sorted).

  • Unfortunately, I don't believe this method works in Joomla 3 due to not being able to manually set the numeric value for ordering. – betweenbrain May 1 '14 at 16:46
1

Another option you could try if you wanted to do an Override template would be to duplicate the output of results and make the first just featured articles and the second order by date.

Or for the locations like side bars where you could use modules, you could order them so the first one show title and have just featured articles and the second hide title and have order by date.

just as thoughts...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.