Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • xumbrella Friend
    #194690

    HI 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 Developer
    #522522

    Hi 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.php

    Regards


    1. blog.zip
    croolic Friend
    #538437

    of 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 Moderator
    #538589

    @croolic, Could you please PM me a temporary FTP account? I will have a look at PHP code and give you suggestion then.

    Adam M Moderator
    #538719

    We’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.

    croolic Friend
    #538769

    beautiful. that’s it. thanks a lot adam

Viewing 6 posts - 1 through 6 (of 6 total)

This topic contains 6 replies, has 4 voices, and was last updated by  croolic 9 years, 11 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum