Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 26, 2012, 12:46:31 PM
1 Hour
1 Day
1 Week
1 Month
Forever
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
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
Droplet or snippet request for showing downloads of certain group(s)
Pages: [
1
]
Go Down
Author
Topic: Droplet or snippet request for showing downloads of certain group(s) (Read 1115 times)
Argos
Moderator
Offline
Posts: 2161
Droplet or snippet request for showing downloads of certain group(s)
«
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
Posts: 2858
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
Logged
http://www.ictwacht.nl
= Dutch ICT info
http://www.pcwacht.nl
= My first
both still work in progress, since years.....
Argos
Moderator
Offline
Posts: 2161
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...
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
Posts: 2296
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)
<?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
Posts: 2161
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
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
Posts: 2296
Re: Droplet or snippet request for showing downloads of certain group(s)
«
Reply #5 on:
November 03, 2010, 11:43:40 PM »
Quote from: Argos on November 03, 2010, 11:39:03 PM
Works like a charm
[[droplets?cool=true]]
Logged
Professional WebsiteBaker Solutions
dbs
WebsiteBaker Org e.V.
Offline
Posts: 3719
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:
$returnvalue .= '<tr>';
$returnvalue .= '
<td colspan="4">'.$file['description'].'</td>';
$returnvalue .= '</tr>';
Logged
Argos
Moderator
Offline
Posts: 2161
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.
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
Posts: 4884
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
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
Posts: 2296
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.
Logged
Professional WebsiteBaker Solutions
pcwacht
AddOn Development
Offline
Posts: 2858
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:
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
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
Posts: 4884
Re: Droplet or snippet request for showing downloads of certain group(s)
«
Reply #11 on:
November 04, 2010, 09:58:34 PM »
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?
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
Posts: 4884
Re: Droplet or snippet request for showing downloads of certain group(s)
«
Reply #12 on:
November 04, 2010, 11:16:28 PM »
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)
<?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'
].
'&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'
].
'&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
Posts: 16
Re: Droplet or snippet request for showing downloads of certain group(s)
«
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
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...