-
AuthorPosts
-
xumbrella Friend
xumbrella
- Join date:
- June 2010
- Posts:
- 100
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 6
- Thanked:
- 2 times in 1 posts
February 11, 2014 at 2:03 pm #194690HI I would like to know… if it is possible to make my site display the top 5 (or any other amount) posts on the wall as the most recent featured articles and then everything after than displayed in order of newest first? if it is possible, can you use leading articles and intro articles to do this?
thanks.
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
February 13, 2014 at 9:25 am #522522Hi xumbrella,
I can confirm this is possible.Though it will require much customization
You need to query 5 first featured article as your request.
// Get an instance of the generic articles model
$show_featured = (
$this->params->def('show_pagination', 2) == 1 ||
($this->params->get('show_pagination') == 2 && $this->pagination->get('pages.total') > 1))
? $this->pagination->get('pages.current') < 2 : true;if($show_featured){
$featured = JModelLegacy::getInstance('Featured', 'ContentModel', array('ignore_request' => true));
// Set application parameters in model
$app = JFactory::getApplication();
$appParams = $app->getParams();
$fparams = clone $appParams;$fparams->set('num_leading_articles', 5); //this is the limit
$fparams->set('num_intro_articles', 0);
$fparams->set('num_links', 0);$featured->setState('params', $fparams);
// Limit - we do not really need it
$featured->setState('list.start', 0);
$featured->setState('list.limit', 5);// Set the filters based on the module params
$featured->setState('filter.published', 1);// Access filter
$access = !JComponentHelper::getParams('com_content')->get('show_noauth');
$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
$featured->setState('filter.access', $access);// Ordering
$featured->setState('list.ordering', 'a.ordering');
$featured->setState('list.direction', 'ASC');// New Parameters
$featured->setState('filter.frontpage', true);// Filter by language
$featured->setState('filter.language', $app->getLanguageFilter());$featured_items = $featured->getItems();
}
Then render those feature articles
if($show_featured){
foreach ($featured_items as &$item):$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$item->catslug = ($item->category_alias) ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = ($item->parent_alias) ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
// No link for ROOT category
if ($item->parent_alias == 'root') {
$item->parent_slug = null;
}$item->event = new stdClass();
$dispatcher = JDispatcher::getInstance();
// Old plugins: Ensure that text property is available
if (!isset($item->text))
{
$item->text = $item->introtext;
}
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onContentPrepare', array ('com_content.featured', &$item, &$this->params, 0));// Old plugins: Use processed text as introtext
$item->introtext = $item->text;$results = $dispatcher->trigger('onContentAfterTitle', array('com_content.featured', &$item, &$item->params, 0));
$item->event->afterDisplayTitle = trim(implode("n", $results));$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.featured', &$item, &$item->params, 0));
$item->event->beforeDisplayContent = trim(implode("n", $results));$results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.featured', &$item, &$item->params, 0));
$item->event->afterDisplayContent = trim(implode("n", $results));$this->item = &$item;
echo $this->loadTemplate('item');
endforeach;
}
I will attach the code here.
You just need to BACK UP and overwrite file: templatesja_wallhtmlcom_contentcategoryblog.phpRegards
1 user says Thank You to Wall Crasher for this useful post
June 10, 2014 at 8:03 am #538437of course it’s working. but there are two problems. i’m not skilfull in php, and don’t now how to resolve these. firstable featured articles are on the top, and at the main stream as well. what to change not showing featured articles for second time? another problem is loading featured articles when i scroll the screen. there is no more articles for loading but featured articles are still loading. how to code blog.php to avoid those two problems?
Adam M ModeratorAdam M
- Join date:
- May 2014
- Posts:
- 5159
- Downloads:
- 33
- Uploads:
- 66
- Thanks:
- 95
- Thanked:
- 1271 times in 1235 posts
Adam M ModeratorAdam M
- Join date:
- May 2014
- Posts:
- 5159
- Downloads:
- 33
- Uploads:
- 66
- Thanks:
- 95
- Thanked:
- 1271 times in 1235 posts
June 12, 2014 at 10:00 am #538719We’re going to modify Article Order a little bit so it will display ‘Featured Articles Order’ first, then all remaining articles will be displayed with ‘Most recent first’ type.
Please open the file your_root_folder/components/com_content/helpers/query.php and look for this syntax:
case 'front' :
$orderby = 'a.featured DESC, fp.ordering';
break;and modify as follows:
case 'front' :
$orderby = 'a.featured DESC,' . $queryDate . ' DESC ';
break;Then go back to Menus >>> choose your current menu >>> edit menu item >>> switch to tab Blog Layout >>> in ‘Article Order’ choose ‘Featured Articles Order’.
Hope it helps.
-
AuthorPosts
This topic contains 6 replies, has 4 voices, and was last updated by croolic 10 years, 5 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum