categories

Phoca Gallery - image gallery extension
donkeyslo
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 12 Mar 2009, 15:32

categories

Post by donkeyslo »

Hi!

I have searched the forum, googled, etc. but didn't find the answer ...
I have a question concerning dispaying of categories, for example if I display categories in 4 columns, each column is displayed as a table, each category in one row ... the problem is, that if i want the categories displayed in a horizontal order (the second category is right to the first and not below it), it is somehow tricky to get them in that order and if I add another category, ther order breaks apart ...
I saw in the template, that you have a part of code for displaying unordered lists, which would come more handy in this case, but can't find where to switch it from tables to list ... if it is possible at all?

Thank you for the answer and hope you continue the amazing job you are doing ...

Greetings, Matej
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: categories

Post by Jan »

Hi, tables are displayed if you want to have thumbnails next to category names. But displaying tables (images + category names) and ul list (only category names) has no influence on float boxes which are created if you want to display more columns

E.g. two columns, 4 categories:
UL - LI

|UL |UL |
|LI 1.category/LI|LI 3.category/LI|
|LI 2.category/LI|LI 4.category/LI|
|/UL |/UL |

TABLE TR TD
|TABLE |TABLE |
|TR TD 1.category/TD /TR|TR TDTR TD 3.category/TD /TR/TD /TR|
|TR TD2.category/LI| 4.category|
|/TABLE |/TABLE |

If you want to display the ordering using horizontal rules then it needs to be changed in template (Html), see:
e.g. here: components\com_phocagallery\views\categories\tmpl\default.php
If you find Phoca extensions useful, please support the project
DiStefano
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 29 Jan 2009, 16:09

Re: categories

Post by DiStefano »

And could you maybe tell me what I need to change to get the ordering using horizontal rules? I am kinda puzzled... :roll:
xpla
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 14 Mar 2009, 21:38

Re: categories

Post by xpla »

I'd also be very happy if you could explain how to achieve horizontal ordering rules because i have the same problem and want it displayed like this:

10 - 9 - 8
7 - 6 - 5

and not

10 - 8 - 6
9 - 7 - 5
xpla
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 14 Mar 2009, 21:38

Re: categories

Post by xpla »

Got a solution, will post it, have to refine it.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: categories

Post by Jan »

Ok, great.
If you find Phoca extensions useful, please support the project
DiStefano
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 29 Jan 2009, 16:09

Re: categories

Post by DiStefano »

Hi xpla,

Looking forward to your solution!

Greetings,
DiStefano
spameur
Phoca Member
Phoca Member
Posts: 10
Joined: 24 Feb 2008, 21:29
Location: France

Re: categories

Post by spameur »

Hi,
Yes, I confirm the mess to order using horizontal rules. :x
Since May, no solution...
I think Jan might consider a special help on this request and include it as a todo. :wink:
Anyway, thanks for this great component.
spameur
Phoca Member
Phoca Member
Posts: 10
Joined: 24 Feb 2008, 21:29
Location: France

Re: categories

Post by spameur »

Hi,
As Jan is very busy, I guess, I did it. :idea:
Works on my servers.
Hope you will enjoy. :D
Mercabilis

File: components\com_phocagallery\views\categories\tmpl\default.php

Code: Select all

<?php
/*
 * @Horizontal Categories for Phoca Component
 * @copyright Copyright (C) 2009 Bonaldi - http://bonaldi.fr
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 *
 * @component Phoca Component
 * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */

defined('_JEXEC') or die('Restricted access'); 
if ($this->tmpl['phocagallerywidth'] != '') {
	$centerPage = '';
	if ($this->tmpl['phocagallerycenter'] == 1) {
		$centerPage = 'margin: auto;';
	}
	echo '<div id="phocagallery" style="width:'. $this->tmpl['phocagallerywidth'].'px;'.$centerPage.'">';
} else {
	echo '<div id="phocagallery">';
}

if ( $this->params->def( 'show_page_title', 1 ) ) { ?>
	<div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
		<?php echo $this->params->get('page_title'); ?>
	</div>
<?php } ?>


<div class="contentpane<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php if ( ($this->params->def('image', -1) != -1) || $this->params->def('show_comp_description', 1) ) : ?>
	<div class="contentdescription<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
	<?php
		if ( isset($this->tmpl['image']) ) :  echo $this->tmpl['image'] . '<div style="clear:both"></div>';  endif;
		echo $this->params->get('comp_description');
	?>
	</div>
<?php endif;?>
</div>

<?php
echo '<form action="'.$this->tmpl['action'].'" method="post" name="adminForm">';

$columns 			= (int)$this->tmpl['categoriescolumns'];
$countCategories 	= count($this->categories);
$begin				= array();
$end				= array();
$begin[0]			= 0;// first
$begin[1]			= ceil ($columns);
$end[0]				= $begin[1] -1;

for ( $j = 2; $j < $columns; $j++ ) {
	$begin[$j]	= ceil(($columns) * $j);
	$end[$j-1]	= $begin[$j] - 1;
}
$end[$j-1]		= $countCategories - 1;// last
$endFloat		= $countCategories - 1;


// -------------------
// TABLE LAYOUT
// -------------------
if ($this->tmpl['displayimagecategories'] == 1) {	
	for ($i = 0; $i < $countCategories; $i++) {
		if ( $columns == 1 ) {
			echo '<table>';
		} else {
			$float = 0;
			foreach ($begin as $k => $v) {
				if ($i == $v) {
					$float = 1;
				}
			}
			if ($float == 1) {		
				echo '<div style="position:relative;float:left;margin:0px;"><table><tr>';
			}
		}

		echo '<td align="center" valign="top" style="'.$this->tmpl['imagebg'].';text-align:center;"><a href="'.$this->categories[$i]->link.'">'.JHTML::_( 'image.site', $this->categories[$i]->linkthumbnailpath, '', '', '', $this->categories[$i]->title, 'style="border:0"' ).'<br /></a>'.'<a href="'.$this->categories[$i]->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$this->categories[$i]->title.'</a>&nbsp;';
		
		if ($this->categories[$i]->numlinks > 0) {echo '<span class="small">('.$this->categories[$i]->numlinks.')</span>';}
		
		echo '</td>';
		
		if ( $columns == 1 ) {
			echo '</tr></table>';
		} else {
			if ($i == $endFloat) {
				echo '</tr></table></div><div style="clear:both"></div>';
			} else {
				$float = 0;
				foreach ($end as $k => $v)
				{
					if ($i == $v) {
						$float = 1;
					}
				}
				if ($float == 1) {		
					echo '</tr></table></div>';
				}
			}
		}
	}
}
 
// -------------------
// DETAIL LAYOUT
// -------------------

else if ($this->tmpl['displayimagecategories'] == 2){
	
	echo '<div id="phocagallery-categories-detail">';
	
	for ($i = 0; $i < $countCategories; $i++) {
		
		// - - - - -
		if ( $columns == 1 ) {
			echo '<div>';
		} else {
			$float = 0;
			foreach ($begin as $k => $v) {
				if ($i == $v) {
					$float = 1;
				}
			}
			if ($float == 1) {		
				echo '<div style="position:relative;float:left;margin:0px">';
			}
		}
		// - - - - -
	
		echo '<fieldset>'
			.' <legend>'
			.'  <a href="'.$this->categories[$i]->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$this->categories[$i]->title_self.'</a> ';
			
		if ($this->categories[$i]->numlinks > 0) {
			echo '<span class="small">('.$this->categories[$i]->numlinks.')</span>';
		}
			
		echo ' </legend>';
		
		echo '<div style="padding:0;margin:0;margin-top:10px;margin-bottom:5px">'
		    .'<div style="position:relative;float:left;margin:0;padding:0">'
		    .' <table border="0" cellpadding="0" cellspacing="0">'
			.'  <tr>'
		    .'   <td style="'.$this->tmpl['imagebg'].';text-align:center;"><a href="'.$this->categories[$i]->link.'">'.JHTML::_( 'image.site', $this->categories[$i]->linkthumbnailpath, '', '', '', $this->categories[$i]->title, 'style="border:0"' ).'</a></td>'
			.'  </tr>'
			.' </table>'
			.'</div>';
		
		
		echo '<div style="margin-right:0px;margin-left:'.$this->tmpl['imagewidth'].'px;">';
		if ($this->categories[$i]->description != '') {
		   echo '<div>'.$this->categories[$i]->description.'</div><p>&nbsp;</p>';
		}
		echo '<table border="0" cellpadding="0" cellspacing="0" >';
		if ( $this->categories[$i]->username != '') {
			echo '<tr><td>'.JText::_('Author') .': </td>'
			    .'<td>'.$this->categories[$i]->username.'</td></tr>';
		}
		
		echo '<tr><td>'.JText::_('Number of images in category') .': </td>'
		.'<td>'.$this->categories[$i]->numlinks.'</td></tr>'
		.'<tr><td>'.JText::_('Category viewed') .': </td>'
		.'<td>'.$this->categories[$i]->hits.' x</td></tr>';

		// Rating
		if ($this->tmpl['displayrating'] == 1) {
			$votesCount = $votesAverage = $votesWidth = 0;
			if (!empty($this->categories[$i]->ratingcount)) {
				$votesCount = $this->categories[$i]->ratingcount;
			}
			if (!empty($this->categories[$i]->ratingaverage)) {
				$votesAverage = $this->categories[$i]->ratingaverage;
				if ($votesAverage > 0) {
					$votesAverage 	= round(((float)$votesAverage / 0.5)) * 0.5;
					$votesWidth		= 22 * $votesAverage;
				}
				
			}
			if ((int)$votesCount > 1) {
				$votesText = 'votes';
			} else {
				$votesText = 'vote';
			}
			
			echo '<tr><td>' . JText::_('Rating'). ': </td>'
				.'<td>' . $votesAverage .' / '.$votesCount . ' ' . JText::_($votesText). '</td></tr>'
				.'<tr><td>&nbsp;</td>'
				.'<td>'
				.' <ul class="star-rating">'
				.'  <li class="current-rating" style="width:'.$votesWidth.'px"></li>'
				.'   <li><span class="star1"></span></li>';
			for ($r = 2;$r < 6;$r++) {
				echo '<li><span class="stars'.$r.'"></span></li>';
			}
			echo '</ul>'
				 .'</td>'
				 .'</tr>';
		}
		
		echo '</table>'
			 .'</div>'
		     //.'<div style="clear:both;"></div>'
			 .'</div>'
		     .'</fieldset>';
	
		// - - - - - 
		if ( $columns == 1 ) {
			echo '</div>';
		} else {
			if ($i == $endFloat) {
				echo '</div><div style="clear:both"></div>';
			} else {
				$float = 0;
				foreach ($end as $k => $v) {
					if ($i == $v) {
						$float = 1;
					}
				}
				if ($float == 1) {		
					echo '</div>';
				}
			}
		}
		// - - - - -
	}
	echo '</div>';

}

// -------------------
// UL LAYOUT
// -------------------
else {
	for ($i = 0; $i < $countCategories; $i++) {
		if ( $columns == 1 ) {
			echo '<ul>';
		} else {
			$float = 0;
			foreach ($begin as $k => $v) {
				if ($i == $v) {
					$float = 1;
				}
			}
			if ($float == 1) {		
				echo '<div style="position:relative;float:left;margin:0px"><ul>';
			}
		}
		
		echo '<li><a href="'.$this->categories[$i]->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$this->categories[$i]->title.'</a>&nbsp;';
		
		if ($this->categories[$i]->numlinks > 0) {echo '<span class="small">('.$this->categories[$i]->numlinks.')</span>';}
		
		echo '</li>';
		
		if ( $columns == 1 ) {
			echo '</ul>';
		} else {
			if ($i == $endFloat) {
				echo '</ul></div><div style="clear:both"></div>';
			} else {
				$float = 0;
				foreach ($end as $k => $v)
				{
					if ($i == $v) {
						$float = 1;
					}
				}
				if ($float == 1) {		
					echo '</ul></div>';
				}
			}
		}
	}
}


if (count($this->categories)) {
	echo '<div><center>';
	if ($this->params->get('show_pagination_limit_categories')) {
		
		echo '<div style="margin:0 10px 0 10px;display:inline;">'
			.JText::_('Display Num') .'&nbsp;'
			.$this->tmpl['pagination']->getLimitBox()
			.'</div>';
	}
	
	if ($this->params->get('show_pagination_categories')) {
	
		echo '<div style="margin:0 10px 0 10px;display:inline;" class="sectiontablefooter'.$this->params->get( 'pageclass_sfx' ).'" >'
			.$this->tmpl['pagination']->getPagesLinks()
			.'</div>'
		
			.'<div style="margin:0 10px 0 10px;display:inline;" class="pagecounter">'
			.$this->tmpl['pagination']->getPagesCounter()
			.'</div>';
	}
	echo '</center></div>';
}
echo '</form>';

echo '<div>&nbsp;</div>';

echo $this->tmpl['phocagalleryic'];?>
</div>
crysun
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 07 Jun 2009, 18:25
Contact:

Re: categories

Post by crysun »

thanks ...
Post Reply