Droplet or snippet request for showing downloads of certain group(s)

nuke

Stefek and Ruud - this helped me out a lot! Thank you!

Quote from: Ruud 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 '<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]

Stefek

Quote from: Ruud 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.
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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Stefek

Quote from: Stefek 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
Quote from: Ruud on November 04, 2010, 01:24:41 PM
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['file']) OR !is_numeric($_GET['file'])) {
//echo "get file ";
header('Location: ../index.php');
} else {
$file = (int) $_GET['file'];
}
if(!isset(
$_GET['id']) OR !is_numeric($_GET['id'])) {
//echo "get id ";
header('Location: ../index.php');
} else {
$prove = (int) $_GET['id'];
}


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

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

pcwacht

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 :
if (!isset($group)) return true; //No group=nn parm given..
to
if (!isset($file_id)) return true; //No file_id=nn parm given..
and
$query_files = $database->query ( 'SELECT * from '.TABLE_PREFIX.'mod_download_gallery_files where `active`=1 AND `group_id` = '.$group );
to:
$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

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

Ruud

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.
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Stefek

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

[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Argos

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!

dbs

very nice !!!
i add the description

                $returnvalue .= '<tr>';
$returnvalue .= ' <td colspan="4">'.$file['description'].'</td>';
$returnvalue .= '</tr>';
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

Ruud

[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Argos

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!

Ruud

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]
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Argos

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

pcwacht

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
[url="http://www.ictwacht.nl"]http://www.ictwacht.nl[/url] = Dutch ICT info
[url="http://www.pcwacht.nl"]http://www.pcwacht.nl[/url] = My first
both still work in progress, since years.....

Argos

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!