The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Section layout override
PostPosted: Tue Mar 02, 2010 1:26 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Feb 22, 2010 1:43 pm
Posts: 8
Hello,

I have written a layout override for the section blog layout. The layout show echo the section's categories and for each category it should show the intro text of the first two articles and links to the rest.

The problem is that currently it shows me two intros of articles from the section according to some sort of internal indexing (not according to article id)

Here is the code:
Code:
<?php
defined('_JEXEC') or die('Restricted access');


$rlu = array();
foreach ($this->items as $i => $item) :
    if (!isset($rlu[$item->catid])) :
        $rlu[$item->catid] = array();
    endif;
    $rlu[$item->catid][] = &$this->items[$i];
endforeach;

?>

<?php if ($this->params->get('show_page_title', 1)) : /*page title */?>
<h1 class="componentheading<?php echo $this->params->get('pageclass_sfx');?>">
    <?php echo $this->escape($this->params->get('page_title')); ?>
</h1>
<?php endif; ?>

<div class="contentdescription<?php echo $this->params->get( 'pageclass_sfx' ); /*section description*/ ?>">
<?php if ($this->params->get('show_description') && $this->section->description) : ?>
   <?php echo $this->section->description; ?>
<?php endif; ?>
</div>

<?php $cat = $this->categories[0]->id;?>

<?php foreach ($this->categories as $category) : /*start echoing the categories */ ?>
   <?php if ($category->id != $cat) {$cat=$category->id; echo "</div>";} ?>
   <div class="category<?= $cat ?>">
    <h2><?php echo $category->title;?></h2>
    <?php if ($category->description) : ?>
    <?php echo $category->description; ?>
    <?php endif; ?>
    <?php if (!empty($rlu[$category->id])) : ?>
    <ul>
        <?php $i=0; ?>
      <?php foreach ($rlu[$category->id] as $article) : /*drill down to category */ ?>   
        <?php if ($i<2) {$this->item =& $this->getItem($i, $this->params); echo $this->loadTemplate('item'); $i++;} else { /*first two articles*/ ?>
      <li>
           
         <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid)); ?>">
                <?php echo $article->title; ?></a>
        </li>
      <?php } ?>
        <?php endforeach; ?>
    </ul>
    <?php endif; ?>
<?php endforeach; ?>
</div>


How can I achieve that?

Thanks a lot,
Alexander

P.S

Thanks a lot to Andrew http://www.theartofjoomla.com/home/6-la ... tents.html

The override is mainly his work here :-)


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 1:39 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 13, 2008 2:57 am
Posts: 20414
Location: Chennai, India
In that menu item that is of the type Section Blog Layout, try to set the following parameters available in the Parameters (Advanced).

Category Order - No, Order by Primary Order Only
Primary Order - choose an option to suit your need

_________________
- Ilagnayeru (MIG) Manickam
http://www.eegan.org - helping the poor and underprivileged
educate. empower. enrich.
Support the poor and underprivileged


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 1:56 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Feb 22, 2010 1:43 pm
Posts: 8
imanickam wrote:
In that menu item that is of the type Section Blog Layout, try to set the following parameters available in the Parameters (Advanced).

Category Order - No, Order by Primary Order Only
Primary Order - choose an option to suit your need


Yes, but how is it going to force the override above to show the intros of the first two articles from each CATEGORY and not just some articles from the SECTION?


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 3:27 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 13, 2008 2:57 am
Posts: 20414
Location: Chennai, India
It is not... Probably, you have to change the Category Order also.

However, the challenge is going to be browsing through the whole result set and choose the appropriate ones. There is some programming involved like setting and resetting variables.

Alternatively, you may have to change the Joomla! core file, most likely the file section.php located in the directory \components\com_content\models where you have to change the where clause that contains sub-query.

_________________
- Ilagnayeru (MIG) Manickam
http://www.eegan.org - helping the poor and underprivileged
educate. empower. enrich.
Support the poor and underprivileged


Top
 Profile  
 
PostPosted: Mon Mar 08, 2010 10:44 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Feb 22, 2010 1:43 pm
Posts: 8
imanickam wrote:
It is not... Probably, you have to change the Category Order also.

However, the challenge is going to be browsing through the whole result set and choose the appropriate ones. There is some programming involved like setting and resetting variables.

Alternatively, you may have to change the Joomla! core file, most likely the file section.php located in the directory \components\com_content\models where you have to change the where clause that contains sub-query.


Easier option: use $article->introtext and that's it.

Solved


Top
 Profile  
 
PostPosted: Mon Mar 08, 2010 1:54 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 13, 2008 2:57 am
Posts: 20414
Location: Chennai, India
Glad to know that you could implement the feature you want.

_________________
- Ilagnayeru (MIG) Manickam
http://www.eegan.org - helping the poor and underprivileged
educate. empower. enrich.
Support the poor and underprivileged


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group