Page 1 of 1

Page navigation in PG 4.2.2

Posted: 31 Dec 2015, 01:35
by mzh1973
Hi, dear forum gurus!
First of all, sorry, I'm not the first with my question. I've searched through the forum and have even found some threads, related to my issue, but either there was no answer, or it was not clear, or maybe I'm not so good in searching and understanding :)
So, the question is:
I've created one empty category and several subcategories with images. Displaying as "List of images (Category view)". Is there any way to display something like page navigation between my subcategories (I don't mean "Back" button, but "previous" and "next" buttons, in the same way, as pagenavigation plugin works in articles.) Thank you very much and sorry for my poor English.

Re: Page navigation in PG 4.2.2

Posted: 31 Dec 2015, 01:39
by Benno

Re: Page navigation in PG 4.2.2

Posted: 02 Jan 2016, 23:39
by mzh1973
Hi, Benno. Thank you for reply, but I'm afraid it's not my case. Or maybe I did not understand again. Or failed to put the question.
I don't need pagination (I meen - navigation between several pages of one category), I prefer to display all images on one page (max. 10-15 in each cat.)
What do I want is the possibility to navigate directly from one category to the next or previous category with the same parent_id.

Re: Page navigation in PG 4.2.2

Posted: 03 Jan 2016, 02:06
by Jan
Hi, for now there is no such option, so this needs to be customized in the code.

In fact you need to modify the code and add sql queries:

When e.g. the category A (ID 25) is displayed, you need to find one previous (e.g. 24) and second next (e.g. 26) and then display links for each in category view.

Similar behavior you can see in detail view (just enable no popup method to see detail view on normal page), the arrows (next, previous) do the trick for images. So you need to customize similar behavior for categories :idea:

Jan

Re: Page navigation in PG 4.2.2

Posted: 04 Jan 2016, 03:02
by mzh1973
Thank you, Jan.

Your advice proved to be helpful.
Finally, I was able to write this code (perhaps you or someone else would be interested):

Code: Select all

// Page Navigation
$t=$this->category->id;
$p=$this->category->parent_id;
//Excluding 1st-lvl categories
if ($p > 0) {

  $user 		= JFactory::getUser();
  $db 		= JFactory::getDBO();
  $app 		= JFactory::getApplication();
  $hideCatArray	= explode( ',', $hide_categories );
  $hideCatSql		= '';
  if (is_array($hideCatArray)) {
    foreach ($hideCatArray as $value) {
      $hideCatSql .= ' AND cc.id != '. (int) trim($value) .' ';
    }
  }
  $query = 'SELECT cc.id AS id'
         . ' FROM #__phocagallery_categories AS cc'
         . ' WHERE `parent_id` = ' . $p . ''
         . ' AND cc.published = 1'
         . ' AND cc.approved = 1'
         . $hideCatSql
         . $hideCatAccessSql
         . ' ORDER BY cc.ordering';

  $db->setQuery( $query );
  $list = $db->loadObjectList();
  $sl = sizeof($list); 
    for ($l=0;$l<=($sl-1);$l++) { 
      $idl[$l] = $list[$l]->id; 
    }

  $CurrentId = $t;
  $KeyCurrent =	array_search($CurrentId, $idl);
  $CountElm = count($idl);
  $NextId = ( $KeyCurrent !== ($CountElm -1) ) 
		? $idl[$KeyCurrent + 1] : 0;
  $PrevId = ( $KeyCurrent == 0 ) 
		? $idl[$CountElm - 1] : $idl[$KeyCurrent - 1];

  if ($NextId!==0&&$NextId!==array_shift($idl)) {
    echo '<div id="next_cat"><a href="'.JRoute::_('index.php?option=com_phocagallery&view=category&id='. $NextId).'">Next</a></div>';
  }
  echo ' ';
  if ($PrevId!==0&&$PrevId!==array_pop($idl)) {
    echo '<div id="next_cat"><a href="'.JRoute::_('index.php?option=com_phocagallery&view=category&id='. $PrevId).'">Prev</a></div>';
  }

}
Added it to views/category/default.php
I'm not sure that this is an universal solution, but at least it works for me :)))
Thank you again!

Re: Page navigation in PG 4.2.2

Posted: 07 Jan 2016, 13:44
by Jan
Hi, ok, great to hear it. Thank you for the guide.

Jan