Author Topic: Droplet or snippet request for showing downloads of certain group(s)  (Read 7539 times)

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
I would like to use the Download Gallery 2 (http://www.websitebakers.com/pages/modules/listings/various/download-gallery-2.php) as a central download repository, and then use a droplet or snippet or some other trick to show the downloads of selected groups on a page.

So if I have 6 different groups of downloads, and I want to show the files of only group 2 and 4 on a certain page, I can use for example a droplet like [[showdownloads?groups=2,4]].

Is this possible? I searched the forum and amasp, but found nothing. This would make a much more flexible solution then using 6 different download sections in the admin. For several reasons I cannot use just 1 download page with all the 6 groups visible.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Offline pcwacht

  • Posts: 2923
  • Gender: Male
    • Dutch ICT info
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #1 on: November 03, 2010, 09:35:33 PM »
Yes it should be possible

Don't think it exists though, and can't help you here cause I don't have downloadgallery installed.

Where you can look is in the view.php of that module, there is the code used wich you can copy and paste and alter ;)


John
http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #2 on: November 03, 2010, 11:18:38 PM »
Ehm... I can't code, that's why I asked for help...  :cry:
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #3 on: November 03, 2010, 11:30:04 PM »
Just a try...

Code: (tested a little bit) [Select]
<?php
global $database;
if (!isset(
$group)) return true//No group=nn parm given..
$returnvalue = &#39;<table>&#39;;
$query_files $database->query ( &#39;SELECT * from &#39;.TABLE_PREFIX.&#39;mod_download_gallery_files where `active`=1 AND `group_id` = &#39;.$group );
if ($query_files) {
while($file $query_files->fetchRow()) {
$url WB_URL . &#39;/modules/download_gallery/dlc.php?file=&#39; .$file[&#39;file_id&#39;];
$returnvalue .= &#39;<tr>&#39;;
$returnvalue .= &#39; <td><a href="&#39;.$url.&#39;" target="_blank">&#39;.$file[&#39;title&#39;].&#39;</a></td>&#39;;
$returnvalue .= &#39; <td>&#39;.gmdate(DATE_FORMAT, $file[&#39;modified_when&#39;]+TIMEZONE).&#39;</td>&#39;;
$returnvalue .= &#39; <td>&#39;.gmdate(TIME_FORMAT, $file[&#39;modified_when&#39;]+TIMEZONE).&#39;</td>&#39;;
$returnvalue .= &#39; <td>&#39;.$file[&#39;dlcount&#39;].&#39;</td>&#39;;
$returnvalue .= &#39;</tr>&#39;;
}
}
$returnvalue .= &#39;</table>&#39;;
return $returnvalue;
?>

Name it "download", call with [[download?group=nn]]

[edit]
Added the `active`=1 in the query to show only active records
[/edit]
« Last Edit: November 03, 2010, 11:42:33 PM by Ruud »

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #4 on: November 03, 2010, 11:39:03 PM »
WONDERFUL! Works like a charm  :-D
Thank you so much, Ruud, very cool stuff. I'm sure others may find the droplet useful too, so maybe you can add it to the official repository.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #5 on: November 03, 2010, 11:43:40 PM »
Works like a charm  :-D

[[droplets?cool=true]]

Offline dbs

  • Betatester
  • **
  • Posts: 8010
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #6 on: November 04, 2010, 08:44:20 AM »
very nice !!!
i add the description
Code: [Select]

                $returnvalue .= '<tr>';
$returnvalue .= ' <td colspan="4">'.$file['description'].'</td>';
$returnvalue .= '</tr>';

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #7 on: November 04, 2010, 11:26:34 AM »
Yes, in the same way other info can be added, like filesize (in my opinion the most important extra info) and filetype image. You can also style the output with classes if you want.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #8 on: November 04, 2010, 01:19:52 PM »
Very nice one indeed.

Maybe giving a new parameter to show only a unique Download (by download ID) at wish instead of a whole group?
May be interesting for example in a kind of "Blog-Entry" where you want to put a unique download at the end of the Text (or somewhere else).

Regards,
Stefek

"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #9 on: November 04, 2010, 01:24:41 PM »
If you know the file-id, it is just a fixed link you can add with your editor. Seems a bit overkill to use a script for that.

Offline pcwacht

  • Posts: 2923
  • Gender: Male
    • Dutch ICT info
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #10 on: November 04, 2010, 04:05:28 PM »
Though I am with Ruud on this one this will show everyone how easy droplets are when you know a litle bit of php / mysql.

copy the dropletcode and change :
Code: [Select]
if (!isset($group)) return true; //No group=nn parm given..to
Code: [Select]
if (!isset($file_id)) return true; //No file_id=nn parm given..and
Code: [Select]
$query_files = $database->query ( 'SELECT * from '.TABLE_PREFIX.'mod_download_gallery_files where `active`=1 AND `group_id` = '.$group );to:
Code: [Select]
$query_files = $database->query ( 'SELECT * from '.TABLE_PREFIX.'mod_download_gallery_files where `file_id` = $file_id ' );
and rename the droplet giving it a meaningfull name ;)

Have fun,
John

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #11 on: November 04, 2010, 09:58:34 PM »
Very nice one indeed.

Maybe giving a new parameter to show only a unique Download (by download ID) at wish instead of a whole group?
May be interesting for example in a kind of "Blog-Entry" where you want to put a unique download at the end of the Text (or somewhere else).

Regards,
Stefek
Seems a bit overkill to use a script for that.
je bent een grapje, toch?  :-D

However, I tried the droplet but the download itself doesn't seem to work.
It seems the timestamp is missing on the link (the download_gallery/dlc.php seems to ask for this parameta via $_GET).

Code: (download_gallery/dlc.php (excerpt)) [Select]
<?php 
if(!isset($_GET[&#39;file&#39;]) OR !is_numeric($_GET[&#39;file&#39;])) {
//echo "get file ";
header(&#39;Location: ../index.php&#39;);
} else {
$file = (int) $_GET[&#39;file&#39;];
}
if(!isset(
$_GET[&#39;id&#39;]) OR !is_numeric($_GET[&#39;id&#39;])) {
//echo "get id ";
header(&#39;Location: ../index.php&#39;);
} else {
$prove = (int) $_GET[&#39;id&#39;];
}

I am going to fix this and will implement the second parameter for unique items.

Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #12 on: November 04, 2010, 11:16:28 PM »
If you know the file-id, it is just a fixed link you can add with your editor.
Hello Ruud,
yes, thats right, but if you provide a download, you maybe want to show the download count too?

For that purpose it's better to have a droplet, right?

I advanced the droplet script a little bit (see instructions after the code):
Code: (suggested Droplet-Name-> download) [Select]
<?php
global $database;
$ret_val "";
$download_url WB_URL '/modules/download_gallery/dlc.php?file=';
if (!isset(
$group) && !isset($item))
$ret_val "you must specify a group or a item ID from your download gallery";

elseif(isset(
$item)){
// UNIQUE DOWNLOAD ITEM
$query_unique_file $database->query(sprintf("SELECT * from `%s` WHERE `file_id` = '%d'"
TABLE_PREFIX."mod_download_gallery_files"$item));
if ($query_unique_file) {
while($file $query_unique_file->fetchRow()) {
$ret_val .= '<div class="unique_download">'
.'<a href="'.$download_url.$file['file_id'].'&amp;id='.$file['modified_when'].'" target="_blank">'
.$file['title']
.'</a><small> DL:'.$file['dlcount'].'</small>'
.'<div>'.$file['description'].'</div></div>';
}
}
}
elseif(isset(
$group)){
// GROUP
$query_files $database->query(sprintf("SELECT * from `%s` WHERE `active`=1 AND `group_id` = '%d'"
TABLE_PREFIX."mod_download_gallery_files"$group));
$ret_val '<table border="1">';
if ($query_files) {
while($file $query_files->fetchRow()) {
$ret_val .= '<tr>'
.' <td><a href="'.$download_url.$file['file_id'].'&amp;id='.$file['modified_when'].'" target="_blank">'.$file['title'].'</a></td>'
.' <td>'.gmdate(DATE_FORMAT$file['modified_when']+TIMEZONE).'</td>'
.' <td>'.gmdate(TIME_FORMAT$file['modified_when']+TIMEZONE).'</td>'
.' <td>'.$file['dlcount'].'</td>'
.'</tr>';
}
}
$ret_val .= '</table><br>';
}

return 
$ret_val;

[[download?group=3]] will return the whole groupID 3 (as before)
[[download?item=7]] will return a unique download of fileID 7 only.

Do not mix the parameters. Use only "group" or only "item".
To find out the ID go to the Download Gallery Page/Section of your WB Installation and go over the items with your mouse. You will find it in the browser status bar.

You should handle all the "template" stuff inside the droplet itself.

You may also use additional output from the database:
$file['filename']
$file['extension']
$file['description']
$file['size']

(see database table for more)

Regards,
Stefek
« Last Edit: April 19, 2013, 05:30:34 PM by Stefek »
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline nuke

  • Posts: 31
Re: Droplet or snippet request for showing downloads of certain group(s)
« Reply #13 on: September 14, 2012, 09:41:12 PM »
Stefek and Ruud - this helped me out a lot! Thank you!

Just a try...

Code: (tested a little bit) [Select]
<?php
global $database;
if (!isset(
$group)) return true//No group=nn parm given..
$returnvalue '<table>';
$query_files $database->query 'SELECT * from '.TABLE_PREFIX.'mod_download_gallery_files where `active`=1 AND `group_id` = '.$group );
if (
$query_files) {
while($file $query_files->fetchRow()) {
$url WB_URL '/modules/download_gallery/dlc.php?file=' .$file['file_id'];
$returnvalue .= '<tr>';
$returnvalue .= ' <td><a href="'.$url.'" target="_blank">'.$file['title'].'</a></td>';
$returnvalue .= ' <td>'.gmdate(DATE_FORMAT$file['modified_when']+TIMEZONE).'</td>';
$returnvalue .= ' <td>'.gmdate(TIME_FORMAT$file['modified_when']+TIMEZONE).'</td>';
$returnvalue .= ' <td>'.$file['dlcount'].'</td>';
$returnvalue .= '</tr>';
}
}
$returnvalue .= '</table>';
return 
$returnvalue;
?>

Name it "download", call with [[download?group=nn]]

[edit]
Added the `active`=1 in the query to show only active records
[/edit]

 

postern-length