But frankly I didn't like the layout of the sections view, and I did like the layout of the single section view. So I set out to turn the sections view into a what looks like a repetitive section view - with the image and the description. I thought it might be nice to share here how I did it.
The first file to change is the model. The reason is that the sections model, unlike the section model, does not query the database for the image file and the description of sections. The file to edit is:
components/com_phocadownload/models/section.php
In line 93, where there is the first line of the query of the _getSectionListQuery method, you have to insert "s.image, s.description, " so that it ends up looking like this:
Code: Select all
$query = " SELECT s.id, s.title, s.alias, s.image, s.description, COUNT(cc.id) AS numcat, '' AS categories"The second file to work on is the sections view, which is found at:
components/com_phocadownload/views/sections/tmpl/default.php
You can either edit that file or you can use it to make a template override which I think is the best way. To make an override you can copy the file to templates/[yourtemplate]/html/com_phocadownload/sections/default.php.
In that file, you have to delete the following:
Code: Select all
// Categories
$numDoc = 0;
$catOutput = '';
foreach ($value->categories as $valueCat) {
$catOutput .= '<p class="pd-category">';
//$catOutput .= '<a href="'. JRoute::_('index.php?option=com_phocadownload&view=category&id='.$valueCat->id.':'.$valueCat->alias.'&Itemid='. JRequest::getVar('Itemid', 1, 'get', 'int')).'">'. $valueCat->title.'</a>';
$catOutput .= '<a href="'. JRoute::_(PhocaDownloadHelperRoute::getCategoryRoute($valueCat->id, $valueCat->alias, $value->id)).'">'. $valueCat->title.'</a>';
if ($this->tmpl['displaynumdocsecs'] == 1) {
$catOutput .=' <small>('.$valueCat->numdoc .')</small>';
}
$catOutput .= '</p>' . "\n";
$numDoc = (int)$valueCat->numdoc + (int)$numDoc;
}
echo '<div class="pd-sections"><div><div><div><h3>';
//echo '<a href="'. JRoute::_('index.php?option=com_phocadownload&view=section&id='.$value->id.':'.$value->alias.'&Itemid='. JRequest::getVar('Itemid', 1, 'get', 'int')).'">'. $value->title.'</a>';
echo '<a href="'. JRoute::_(PhocaDownloadHelperRoute::getSectionRoute($value->id, $value->alias)).'">'. $value->title.'</a>';
if ($this->tmpl['displaynumdocsecsheader'] == 1) {
echo ' <small>('.$value->numcat.'/' . $numDoc .')</small>';
}
echo '</h3>';
echo $catOutput;
echo '</div></div></div></div>';
if ($i%3==0) {
echo '<div style="clear:both"></div>';
}
$i++;
Code: Select all
echo '<div id="phoca-dl-section-box">';
echo '<div class="pd-section">';
echo '<h3><a href="'. JRoute::_(PhocaDownloadHelperRoute::getSectionRoute($value->id, $value->alias)).'">'. $value->title.'</a></h3>';
if (!empty($value->image)) {
$attribs['align'] = '"'.$value->image_position.'"';
$attribs['hspace'] = '"6"';
$image = JHTML::_('image', 'images/stories/'.$value->image, JText::_('Phoca Download'), $attribs);
} else {
$image = '';
}
echo '<div class="contentpane'.$this->params->get( 'pageclass_sfx' ).'">';
if ( (isset($image) && $image !='') || (isset($value->description) && $value->description != '' && $value->description != '<p> </p>')) {
echo '<div class="contentdescription'.$this->params->get( 'pageclass_sfx' ).'">';
if ( isset($image) ) {
echo $image;
}
echo $value->description
.'</div>';
}
echo '</div>';
if (!empty($value->categories)) {
foreach ($value->categories as $valueCat) {
echo '<p class="pd-category">';
echo '<a href="'. JRoute::_(PhocaDownloadHelperRoute::getCategoryRoute($valueCat->id, $valueCat->alias, $value->id)).'">'. $valueCat->title.'</a>';
echo ' <small>('.$valueCat->numdoc.')</small></p>' . "\n";
}
echo '</div>';
} else {
echo '<p> </p><p> </p>';
}
echo '<p> </p></div>' ;
Now, each section listed in the sections view will look almost exactly as if it was shown in the section view.
Frankly, I'd recommend these changes to be made to the view as distributed but I suppose that's a matter of taste. In any case, to my taste, now Phoca Download looks great on every page!

