a new view: sections looking like section

Phoca Download - download manager
ewel
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 28 Apr 2008, 17:52

a new view: sections looking like section

Post by ewel »

I am trying to make a site where certain user groups get access to selected downloads, and users will get access to one or more sections in Phoca Download depending on their access rights. So the sections view is the best for this purpose, because if everything goes well users will get to see only those sections that they are allowed to see.

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++;
Finally, replace what you just deleted by this:

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>&#160;</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>&nbsp;</p><p>&nbsp;</p>';
		}   
			echo '<p>&nbsp;</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!
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49144
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: a new view: sections looking like section

Post by Jan »

Hi, thank you for this improvement.

Jan
If you find Phoca extensions useful, please support the project
jbourque
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 21 Jul 2010, 01:52

Re: a new view: sections looking like section

Post by jbourque »

Ewel,

I have been trying to get this to work so however I'm getting an error in the section.php file with an

Parse error: syntax error, unexpected T_VARIABLE in /home/appealt/public_html/components/com_phocadownload/models/section.php on line 94

Could you attach the 2 files

Joe
jbourque
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 21 Jul 2010, 01:52

Re: a new view: sections looking like section

Post by jbourque »

I found what I did wrong was missing a ; semicolon

I was hoping that this would add the description to the right side of the title in the section area

Joe
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49144
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: a new view: sections looking like section

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply