Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 12:46:31 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155537 Posts in 21712 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Droplet or snippet request for showing downloads of certain group(s)  (Read 1115 times)
Argos
Moderator
**
Offline Offline

Posts: 2161


WWW
« on: November 03, 2010, 06:12:00 PM »

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.
Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
pcwacht
AddOn Development
*
Offline Offline

Posts: 2858



WWW
« 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 Wink


John
Logged

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

Posts: 2161


WWW
« Reply #2 on: November 03, 2010, 11:18:38 PM »

Ehm... I can't code, that's why I asked for help...  cry
Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« Reply #3 on: November 03, 2010, 11:30:04 PM »

Just a try...

Code: (tested a little bit)
<?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]
« Last Edit: November 03, 2010, 11:42:33 PM by Ruud » Logged

Professional WebsiteBaker Solutions
Argos
Moderator
**
Offline Offline

Posts: 2161


WWW
« Reply #4 on: November 03, 2010, 11:39:03 PM »

WONDERFUL! Works like a charm  grin
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.
Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« Reply #5 on: November 03, 2010, 11:43:40 PM »

Works like a charm  grin

[[droplets?cool=true]]
Logged

Professional WebsiteBaker Solutions
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3719


WWW
« Reply #6 on: November 04, 2010, 08:44:20 AM »

very nice !!!
i add the description
Code:

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

Argos
Moderator
**
Offline Offline

Posts: 2161


WWW
« 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.
Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
Stefek
WebsiteBaker Org e.V.

Online Online

Posts: 4884



« 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

Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« 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.
Logged

Professional WebsiteBaker Solutions
pcwacht
AddOn Development
*
Offline Offline

Posts: 2858



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

Have fun,
John

Logged

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

Online Online

Posts: 4884



« 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?  grin

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))
<?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
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Stefek
WebsiteBaker Org e.V.

Online Online

Posts: 4884



« 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)
<?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: November 04, 2010, 11:34:46 PM by Stefek » Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Schwarzlicht

Offline Offline

Posts: 16


« Reply #13 on: January 26, 2012, 09:22:00 PM »

Hello,

how can I display the name of the group behind the files?

Thank you!!
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!