List Files from Set Block - Pagination

Permalink 1 user found helpful
My requirement is to create a Download Section in the website. I used List files from Set Block to achieve this. It working ok but there is no option for Pagination/page navigation.

What if I have 1000 files to download?? Is there any way I can achieve this List Files from Set block?

Or Is there any other method to achieve a Download Section in Concrete 5 based website?

1 Attachment

jeevanism
 
jeevanism replied on at Permalink Reply
jeevanism
Can any one help me to enable page navigation / pagination in this block?
jeevanism replied on at Permalink Reply
jeevanism
any one, Hello??
wagdi replied on at Permalink Reply
wagdi
jeevanism replied on at Permalink Reply
jeevanism
@wagdi..

thank you for the response. Unfortunately I am not able to buy a premium add on for this. I have to hard code, I have tried to use the Page List/Pagination/search api but its too much confusing (I am still a a newbie into PHP).

I am not sure that I can use multiple pages to list the files since I am using the List files in Set block for this.

Can you tell me the steps to extend a Pagination Api ? anyways, I will keep trying, hope I can hit a remedy soon.
mesuva replied on at Permalink Reply 1 Attachment
mesuva
Hey jeevanism,

I've attached a quickly hacked version of the package to include basic pagination.
My 5 mins of hacking made it work fine, but please be aware that I've taken a few programming shortcuts, it's roughly done, I might not have thought of everything, etc...

Just replace the list_files_from_set folder in your package folder with this one. You shouldn't need to re-install it or do anything else, it's just a few changes to controller.php and view.php. (I didn't change the table_layout view)

I hope this helps. (if it's not quite there, it might at least give you some ideas on how to do the pagination)

I might update my official version at some point.
jeevanism replied on at Permalink Reply
jeevanism
@Mesuwa..

thank you a million for the help.

I just copied the downloaded attachment folder with contents to my block folder. (in webroot/c5/block).

Then I went to my Download page where the List Files from Set block added. I got this error

Fatal error: Cannot redeclare class ListFilesFromSetPackage in /srv/www/htdocs/cefil/blocks/list_files_from_set/controller.php on line 28

please tell me how to fix this?

thank you
mesuva replied on at Permalink Reply
mesuva
It's a full package, so you can't just drop it all into /blocks.

If you are wanting to do this as a block override, you need to unzip what I attached, and then go into its block folder.. inside THAT is the actual block folder, called list_files_from_set. You should be able to copy that into the blocks folder.

In other words, extract the block from the package and copy that in, not drop the whole thing into blocks.
jeevanism replied on at Permalink Reply
jeevanism
@Mesuva

thank you for the correction.

yes, that true. Sorry for my mistake. I unzipped, copy /list_files_from_set/ folder inside my blocks folder. now I go this error

Fatal error: Call to undefined method Permissions::canViewFile() in /srv/www/htdocs/cefil/blocks/list_files_from_set/templates/table_layout.php on line 47


oops.. did I do some thing wrong??
jeevanism replied on at Permalink Reply 2 Attachments
jeevanism
# Update

I fixed that by changing if ($fp->canViewFile()) to if ($fp->canRead())

Now the list of files are shown but the pagination? There are more than 10 files in the set

attaching screenshots..

thank you so much for the response.
mesuva replied on at Permalink Best Answer Reply
mesuva
Good work, I was just about to post that fix (I was assuming you were using 5.6, you must be using 5.5)

In my original post though, I said I DIDN'T change table_layout.php.
So you should be able to just copy the lines:
<?php
if ( $controller->fl && $controller->numberFiles > 0) {
      $paginator = $controller->fl->getPagination();
?>
<span class="ccm-page-left"><?php  echo $paginator->getPrevious('« ' . t('Previous')) ?></span>
<?php  echo $paginator->getPages() ?>
<span class="ccm-page-right"><?php  echo $paginator->getNext(t('Next') . ' »') ?></span>
<?php } ?>

(That I had added to the end of view.php) onto the end of ../templates/table_layout.php
jeevanism replied on at Permalink Reply 1 Attachment
jeevanism
@Mesuva

oops.. its my bad.. (Hands up).. Sorry for being a bafoon I am :-(.

It was table_layout.php I was editing.. I should have tried on No template option.

Now the pagination is there..I can start styling it..


thank you very much for this help.. Seriously..

I have to build more strong knowledge on C5 basic things. :-)
mesuva replied on at Permalink Reply
mesuva
Great to hear!