All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.


Author Topic: page download with category support  (Read 11105 times)

0 Members and 1 Guest are viewing this topic.

Offline webster

  • Newbie
  • *
  • Posts: 3
    • View Profile
page download with category support
« on: 26 January 2008, 20:42 »
Hope you don't mind Lester, but I hacked a few functions to provide [page_downloads_catid] functionality.  Below is an example for anyone who needs this before the 1.30 release.

This hack involves editing downloadmanager.php, so make sure you make a backup before continuing.  You are going to be working with two functions: place_downloadpage() line 327  & downloads_page() line 366.

1) We need to add a new tag to listen for. Replace place_downloads() with:
Code: [Select]
### Function: Place Download Page In Content
# edited by Ryan Mueller, creativenotice.com 01262008
# Hack for inserting downloads by category
# 1)added 2nd replace listening for page_downloads_catid, 2)pass the catid to func downloads_page
add_filter('the_content', 'place_downloadpage', '7');
function place_downloadpage($content){
$content =preg_replace("/\[page_downloads\]/ise", "downloads_page(0)", $content);
$content =preg_replace("/\[page_downloads_catid=(\d+)\]/ise", "downloads_page('\\1')", $content);
    return $content;
}
Notice the new tag we are listing for [page_downloads_catid=xx], that is what you will use when creating your pages in WP.

2) We need to update downloads_page() so it will pull downloads based on catid passed by the previous function. Replace:
Code: [Select]
function downloads_page() {
within downloads_page() with:
Code: [Select]
function downloads_page($catid) {
Next, replace:
Code: [Select]
if($category > 0) {
$category_sql = "WHERE file_category = $category";
}

with
Code: [Select]
if($category > 0 && $catid==0) {
$category_sql = "WHERE file_category = $category";
}elseif ($catid){
$category_sql = "WHERE file_category = $catid";
}

You're good to go.
« Last Edit: 26 January 2008, 23:31 by webster »
Ryan Mueller
CreativeNotice.com

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,294
    • View Profile
Re: page download with category support
« Reply #1 on: 26 January 2008, 22:17 »
Wow... Cool... Nice Job
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline webster

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: page download with category support
« Reply #2 on: 26 January 2008, 23:32 »
Thanks tTech, I just found a bug in my code so I've fixed and updated the code snippets above.
Ryan Mueller
CreativeNotice.com

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: page download with category support
« Reply #3 on: 27 January 2008, 06:07 »
thanks i will sticky this topic and add this to the upcoming release. Can I have your name and URL to add to the changelog credits?

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline webster

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: page download with category support
« Reply #4 on: 27 January 2008, 06:41 »
Wow that's cool! Glad to help.
Ryan Mueller CreativeNotice.com
Ryan Mueller
CreativeNotice.com

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: page download with category support
« Reply #5 on: 27 January 2008, 08:58 »
thanks =D Bookmarked this thread =D

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,294
    • View Profile
Re: page download with category support
« Reply #6 on: 29 January 2008, 22:31 »
:)
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline fabifott

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: page download with category support
« Reply #7 on: 05 February 2008, 20:59 »
here is my solution:

open wp-downloadmanger.php and find
Code: [Select]
### Function: Get Downloads By Category ID
before this line add:

Code: [Select]
### Function: Place Category Page In Content
add_filter('the_content', 'place_categorypage', '7');
function place_categorypage($content){
$content = preg_replace("/\[page_category=(\d+)\]/ise", "get_downloads_category('\\1')", $content);
$content = preg_replace("/\[page_category=(\d+),limit=(\d+)\]/ise", "get_downloads_category('\\1','\\2')", $content);
    return $content;
}

you can use two tags:
[page_category=X] shows 10 files of the category with the id X,
[page_category=X,limit=Y] shows Y files of the category with the id X


Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,294
    • View Profile
Re: page download with category support
« Reply #8 on: 06 February 2008, 02:01 »
Cool. Thank
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline amoss

  • Newbie
  • *
  • Posts: 2
    • View Profile
  • WordPress Version: WordPress 2.8.x
  • Theme Name: Cutline 1.4
Re: page download with category support
« Reply #9 on: 23 January 2010, 19:40 »
Hello,

I am looking for help on using WP-DownloadManager and categories...I've searched, but cannot find an answer to my question...

I run a bilingual site - and use qTranslate, so I have short code capability on the download page for each language.   

I want to be able to have download categories that are for language 1 show up on the language 1 version of download page, and language 2 downloads on the language 2 download page.   I set up my download categories so ODD # are always language 1, EVEN # are always language 2.    So I'd like to just put a short code into the page for language 1 ... what I thought it would look like is [page_download category_id=1,3,5,7,9,11,13,15,17,19,21,23,25] and on the language 1 page, and [page_download category_id=2,4,6,8,10,12,14,16,18,20,22,24,26] on the language 2 page.

Any ideas why this wouldn't be working?

Thanks
AM

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: page download with category support
« Reply #10 on: 24 January 2010, 04:27 »
 [page_download category="2,4,6,8,10,12,14,16,18,20,22,24,26"]

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline amoss

  • Newbie
  • *
  • Posts: 2
    • View Profile
  • WordPress Version: WordPress 2.8.x
  • Theme Name: Cutline 1.4
Re: page download with category support
« Reply #11 on: 24 January 2010, 21:02 »
Many thanks.

AM

Offline flweb

  • Newbie
  • *
  • Posts: 2
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: Thematic
Re: page download with category support
« Reply #12 on: 24 January 2010, 21:57 »
[page_download category="2,4,6,8,10,12,14,16,18,20,22,24,26"]

Doesn't seem to work out of the box for me, I think I have latest version (1.50)

To make it work with multiple category i changed wp-downloadmanager.php:
delete or comment out line 492 that is:
Code: [Select]
$category_id = intval($category_id);at line 510, it was:
Code: [Select]
if($category > 0) {
$category_sql = "AND file_category = $category";
}
it should be:
Code: [Select]
if($category > 0) {
if(strpos($category, ',') !== false) {
$category_sql = "AND file_category IN($category)";
} else {
$category_sql = "AND file_category = $category";
}
}
however this will break line 592 that can easily be fixed but i dont need %FILE_CATEGORY_NAME% in page download header  ;)

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: page download with category support
« Reply #13 on: 25 January 2010, 08:55 »
I think an easier way is to use the [download] shortcode instead of [page_download]
Code: [Select]
[download category="2,4,6,8,10,12,14,16,18,20,22,24,26"]

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline flweb

  • Newbie
  • *
  • Posts: 2
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: Thematic
Re: page download with category support
« Reply #14 on: 25 January 2010, 11:01 »
Sure, but i needed different template for download page and embedded download, so it wasn't a good solution for me.