Page 1 of 1

[SOLVED] Album page count problem

Posted: Thu Jul 19, 2007 3:50 pm
by liudaz
hello,

I am using CMS Made Simple version 1.1 and 0.9.2 album module version (default template).

I am trying to put lets say 50 pictures into one album. And when displaying it, i want them to be shown by pages. As it used to be
(   >>  ) and you get to see 15 thumbnail at a time.
This time, i get to see only the last set of thumbnails. I check the $pagecount variable, and it's value is 1.

Has anyone had this problem before?

Re: Album page count problem

Posted: Mon Jul 30, 2007 6:49 pm
by kdallman
I, too, recently encountered this problem. I would like to limit the amount of thumbnails to three rows and have the rest on subsequent pages. I have set the max number of thumbnail rows in the album properties to three which does indeed limit the rows as I desire. However, something is obviously going wrong as the page navigation does not appear when the thumbnails exceed this limit. The code I am using for page navigation is below.

Code: Select all

{if $pagecount>1}
<p class="albumnav">
{if $link.page.previous}
<a href="{$link.page.previous}" title="previous page" class="previous">< Previous</a>
{/if}
{if $link.page.next}
<a href="{$link.page.next}" title="next page" class="next">Next ></a>
{/if}
</p>
{/if}
I am using an almost identical code for individual image navigation and that always displays when appropriate. I have also tried alternate templates that come with Album...all with no luck. I am at a loss for how to fix this. Any help would be much appreciated.

Re: Album page count problem

Posted: Mon Sep 17, 2007 9:25 am
by cubitus
Hi kdallman & liudaz

Did you successfully solved your problem ?

I've upgraded my site from cms 1.0.8 => 1.1.1 and Album from 0.8.2 => 0.9.2

I get the same problem has you have. I cannot rely anymore on the smarty variable $pagecount . That's weird  ???

Can anyone help me, I relaly want to have this pagination stuff in my album.

When I insert an {debug} at the end of the smarty template, I do not see any  $pagecount variable.


I'm I doing something wrong ?

Any help will be appreciated. Thanks

Re: Album page count problem

Posted: Mon Sep 17, 2007 2:44 pm
by liudaz
Hi,

The only way i could use the pagecount property to work was to use an older versio of CMS Album.
Since noneof the album versions are accesible via admin panel, you can download one from here:
http://dev.cmsmadesimple.org/frs/?group ... ase_id=853
and upload then the xml file (be careful, templates and albums will disapper, if you remove the installed album module and than install new via xml)

I dont remember wich latest version of album was the one that worked, but i think it was 0.8.2

Liudas

Re: Album page count problem

Posted: Mon Sep 17, 2007 3:34 pm
by cubitus
Ok, I think I get it:

In the file class.Album.php the assignement of the smarty's variable "pagecount" is done in line 749.

Code: Select all

$this->smarty->assign('pagecount', $pagecount);
and the corresponding $pagecount php's variable is initialized on line 723

Code: Select all

$pagecount = 1;
Between the initialization of $pagecount and the assignement into smarty, the value is not changed. That's why the following smarty's code gives always false ;D

Code: Select all

{if $pagecount > 1}
 

Later (around line 873) the variable $pagecount is correctly assigned  ;)
The same appends for variable $page  ::)

So the workaround is the following :

Move the two following lines

Code: Select all

$this->smarty->assign('pagecount', $pagecount);
$this->smarty->assign('pagenumber', $page);
After the following code's fragment (aroung line 878) and that's it

Code: Select all

$pagecount = ($picturesbypage > 0 ? ceil(count($allpictures) / $picturesbypage) : 1);
if ($page > $pagecount)
{
   $page = $pagecount;
}
if ($page < 1)
{
   $page = 1;
}
Hope that will help someone

Re: Album page count problem

Posted: Mon Sep 17, 2007 3:37 pm
by liudaz
Great work! Will have to try this later. Thanks alot!

Hopefully this problem will be fixied in the stable release of album :)

liudaz

Re: [SOLVED] Album page count problem

Posted: Tue Aug 25, 2009 1:39 pm
by sn3p
I know this topic is rather old and marked solved, but I think this could still be of use to alot of people.

In the Album admin you can set the amount of columns and rows. It says these settings will only be used for table templates, but that doesn't seem to be the case.

In class.Album.php (~ line 882) the script always counts the pictures per page (columns * rows):

Code: Select all

$picturesbypage = $this->albums[$album_index]->columns * $this->albums[$album_index]->rows;
If $picturesbypage is 0 (when columns or rows is set to 0 in admin) the $pagecount will allways be 1:

Code: Select all

$pagecount = ($picturesbypage > 0 ? ceil(count($allpictures) / $picturesbypage) : 1);
This will prevent the pagination from showing up.


SOLUTION:
1. The easiest way is setting the columns and rows in admin.

2. If you want to use the 'number' parameter you can modify class.Album.php and replace the line (~ line 882, see above) with:

Code: Select all

if (!empty($params['number'])) {
	$picturesbypage = $params['number'];
} else {
	$picturesbypage = $this->albums[$album_index]->columns * $this->albums[$album_index]->rows;
}
This will ignore the columns and rows set in admin if you use the 'number' parameter:
{cms_module module='album' albums='1' number='9'}


EDIT:
By the way, what is the proper way to trigger pagination?
It seems the 'number' parameter isn't used at all when calling the module (with default action).