Wordpress Download Monitor 中文帮助文档

Posted by Hpyer on 2010-03-03, 星期三

  非常感谢您的关注与支持,本页面目前仍在制作当中,将会在近期与大家见面。但由于本人的工作关系,进度可能不会很快。如果有任何问题,可以在此留言,我将尽力解答。当然,由于我并不是插件的制作者,并不一定能解决所有的问题,还请大家谅解,谢谢!

  本页面将会参照官网帮助文档进行汉化。【2010年3月7日更新】

下载地址:官方下载(英文) | :本站下载(中文)

如何安装

  1. 到 wordpress.org 的插件页下载 Download Monitor,中文版请点击这里
  2. 解压缩您下载到的 download-monitor.x.y.z.zip(其中的 x.y.z 为版本号)文件,并将其中的 download-monitor 文件夹上传到您服务器的插件目录(通常为:wp-content/plugins)下。
  3. 登录您的 Wordpress 后台,转到插件页面,并激活(启用)本插件。一旦插件激活成功,程序会自动创建所需的数据表到数据库中。
  4. 如果您可以在 Wordpress 后台看到 ‘下载管理’(英文版为:Downloads) 这一菜单的话,那么恭喜!您已经完成插件的安装。

配置您的 Download Monitor

下载分类

导航:

下载管理 > 分类

您可以在该段落对分类进行管理。分类是可以嵌套的(树形)。从 3.3.3 版起,每个下载文件可以指定多个分类。输入名称并选择一个上级分类(如果您想进行嵌套的话)后点击“添加”按钮即可完成添加分类的操作。

注:每个分类都有一个唯一的 ID。当您在文章中显示分类的时候,此 ID 号将作为参考。

自定义输出样式

导航:

下载管理 > 配置 > 自定义输出样式

您可以在此定义下载链接所输出的样式。自定义样式应该是包含特殊“标签”的 HTML 代码。您可以使用下列会被自动替换为相应下载信息的标签。

  • {url} – 下载文件的 URL 地址(仅仅地址而已)
  • {id} – 下载文件的 ID
  • {user} – 发布者的用户名
  • {version} – 下载文件的版本号
  • {version,"before","after"} – 下载文件的版本号。如果未设置则不输出。请将 before 和 after 分别替换为前后的修饰文本或 HTML 代码。
  • {title} – 下载文件的标题
  • {size} – 文件大小
  • {categories} – 输出以逗号分隔的分类列表。
  • {categories, "link"} – 输出以逗号分隔并包含您所设定了连接样式的分类列表。% 将被替换为分类的 ID,%2 将被替换为分类名。这一标签可以在 [download_page] 中使用。
  • {category,"before","after"} 或 {category} – 第一个分类。请将 before 和 after 分别替换为前后的修饰文本或 HTML 代码。
  • {category_other,"before","after"} 或 {category_other} – 第一个分类(如果未设置分类则返回“其他”)。请将 before 和 after 分别替换为前后的修饰文本或 HTML 代码。
  • {category_ID} – 第一个分类的 ID。
  • {hits} – 当前点击数
  • {hits,"No hits","1 Hit","% hits"} – 格式化输出点击数。% 将被替换为点击数的数字。
  • {image_url} – 下载文件的图片的 URL
  • {description,"before","after"} 或 {description} – 下载文件的描述信息。如果未设置则不输出。请将 before 和 after 分别替换为前后的修饰文本或 HTML 代码。
  • {description-autop,"before","after"} 或 {description-autop} – 自动在前后包含 <p> 和 </p> 的描述信息(转换为空两行的段落)。
  • {date,"Y-m-d"} – 发布日期。第二个参数为需要输出的日期格式。
  • {tags} – 输出以逗号分隔的标签列表。
  • {tags, "link"} – 输出以逗号分隔并包含您所设定了连接样式的标签列表。% 将被替换为标签的 ID,%2 将被替换为标签名。
  • {thumbnail} – 输出缩略图的 URL 地址(或图像占位符)
  • {meta-key} – 自定义字段的值
  • {meta-autop-key} – 自动在前后包含 <p> 和 </p> 的自定义字段的值。
  • {filetype} – 文件类型(如:zip)
  • {filetype_icon} – 文件类型的图标(16x16像素)

示例一:图片样式的下载链接。鼠标悬停在图片上方会显示下载次数

<a href="{url}" title="已下载 {hits} 次"><img src="{image_url}" alt="{title}" /></a>

示例二:文本方式的链接。鼠标悬停在链接上方会显示下载次数,而链接后则紧跟着该下载文件的描述信息

<a href="{url}" title="已下载 {hits} 次" >{title}</a> - {description}

对于分类、自定义样式的调用,都是通过其对应的 ID 进行的,而非名称。

使用自定义样式可以让您自由、灵活的选择自己喜欢的下载样式。例如:链接、列表项或者表格等等 – 一切皆由您喜欢!

自定义下载地址

导航:

下载管理 > 配置 > 自定义下载地址

该选项允许您对文件的下载地址进行伪装,使其更为美观。默认情况下,下载地址为如下样式:

http://yourdomain.com/wp-content/plugins/download-monitor/download.php?id=1

请在文本框中输入一些字符来伪装链接的前半部分。例如输入

downloads/

并保存后,下载地址即可伪装为如下样式:

http://yourdomain.com/downloads/1

请在下拉框(默认为 ID)中选择链接的后半部分样式。例如选择 ‘文件名’ 并保存后,下载地址即可伪装为如下样式:

http://yourdomain.com/downloads/filename.zip

重要说明:请确保您所填写的字符(例如上文将到的 downloads)并不是一个真实存在于服务器上的文件夹,并且它也不能是任何文章/页面的别名,以保证文件可以被正常下载。

设置该选项后,您必须重新保存永久链接以使设置生效。

常规选项

导航:

下载管理 > 配置 > 常规选项

  • “未找到下载链接” 时跳转到 URL – (可选)当用户请求的文件未找到时,页面将会自动跳转到您在此设置的 URL 地址。
  • 当有用户点击了需要登录后才能下载的文件时,所跳转的页面: – (可选)
  • 下载图片的路径 – 当您需要使用 #image 标签或者样式中定义了 {image_url} 标签时,则需要设置该图片地址。
  • 默认输出样式 – (可选)当未指定输出样式的情况下,默认的输出样式。

重建数据库

3.3.3 版起,该功能已被取消。

导航:

下载管理 > 配置 > 重建数据库

如果您发现程序有问题(如无法添加新的下载文件等),则可能是数据库有错误。该功能可以重新创建数据库表格(使用前请先备份您的数据库)。

Top

添加下载文件

文件可以通过三种方式添加

  1. 使用
    下载管理 > 添加文件

    页面来上传并添加一个新文件。

  2. 使用
    下载管理 > 添加已有文件

    页面来选择一个已经上传/远程主机上的文件。 3.3.3 版起被合并到“添加文件”页面中

  3. 使用文章发布页的上传程序(参见下文:‘使用文章发布页的上传程序’)
  4. 使用指定目录进行批量添加。 3.3.3 版起新增

“添加下载文件”的表格应该不需要多做解释了,不过我还是会用以小段文字解释“自定义字段”和“仅会员下载”。新上传的文件会被保存在 wp-content/uploads/downloads/xxxx/xx/ 文件夹中(类似图片的保存方式)。

自定义字段允许您定义关于所添加文件的附加信息 – 只需要添加“名称”和“值”即可。您可以使用

{meta-key}

{meta-autop-key}

这两个自定义样式中的标签来调用字段的数据。它们有各种各样的用处,例如,如果我希望给每个文件包含一个缩略图,那么我可以添加一个名为“thumbnail-path”的自定义字段。然后,我就可以在自定义输出样式中这样使用:

<a href="{url}" title="已下载 {hits} 次"><img src="{meta-thumbnail-path}" alt="缩略图" /> {title}</a>

每个下载文件可以添加多个自定义字段,只要你愿意。

仅会员下载选项,当您勾选这项后,则只有在用户登录后才可以下载。如果用户尚未登录则会看到一个必须登录后才能下载的提示信息,或者页面将被自动转到您在后台设置的当有访客点击了需要登录后才能下载的文件时,所跳转的页面

一个简单的方式是,您可以添加一个名为 min-level 的自定义字段来设置用户下载该文件所需的最小权限。

查看、编辑、删除文件

Download Monitor 的主管理页面中可以查看到所有的下载文件,并且每个下载都有对应的编辑和删除按钮。编辑的页面和添加新下载的页面完全一致。删除的同时也将会删除文件,不过前提是该文件是通过本插件的“添加新下载”的页面上传的。

下载日志

下载管理 > 下载日志

页面中将会列出最近被下载的文件以及用户的 ID 和 IP 地址。这些数据不是用于统计的,所以如果您愿意,可以使用“清空日志”按钮安全的删除所有下载日志。

下载统计

在插件的主管理页面可以查看到下载次数,不过,如果你应该注意到 Wordpress 的后台控制台的两个统计 Widget。一个用于显示最热门的五个下载,另一个则显示每周、每月的下载情况。

widget-screenshots

widget-screenshots

使用文章发布页的上传程序

在 Wordpress 的文章发布页面中,您会在编辑器上方的“添加媒体”图标旁边看到一个“向下的箭头” – 这个箭头可以让您即便在发布文章的时候也能很方便的使用 Download Monitor。

uploader-icon

uploader-icon

在这个界面中,您可以添加一个新文件(并且插入到文章中),或者通过“查看所有下载”按钮来查看到已经添加到 Download Monitor 的文件,找到您要的文件后,点击右边的“插入到文章”即可。

:您看到的插入一句类似

[download id="1"]

的代码是正常的,在用户查看文章的时候,其会被自动解析成对应的下载链接。

Top

输出您的下载

Download monitor 提供了很多方式来将下载输出到您的文章、页面或者模版。

Shortcodes

Shortcodes 是最好的包含下载的方式(以后将会代替传统的标签)。

输出单个下载

[download id="1" format="1" autop="false"]

该 shortcode 根据 format 所指定的自定义样式输出您选择的单个下载(通过设置 id 的值),以及一个可选的 autop 参数(true 或 false,默认 false 并且表示为不用 <p></p> 标签进行封装)。同样有效的使用方法:

[download id="1"]

[download id="2" format="2"]

输出多个下载

[downloads query="limit=5&orderby=rand" format="1" wrap="ul" before="&lt;li&gt;" after="&lt;/li&gt;" autop="false"]

该 shortcode 将检索并输出多个下载到文章中。所有的参数都是可选的。

‘query’ 设置一个包含各种选项的查询字符串(请参阅下文对 get_downloads() 函数的说明,它们使用相同的查询字符串)。默认情况为检索随机的五个下载。通常会使用该 shortcode 来显示一个分类的下载。您可以添加

&category=1

(将 1 替换为要显示的分类的 ID)到查询字符串中。

‘Format’ 设置一个自定义输出样式的 ID 来改变每个下载的输出样式。

‘Wrap’ 默认情况下,所有下载将使用无序列表进行封装。如果您想使用其它方式(例如:表格)进行封装,可以将该选项设置为空白。

‘Before’ 和 ‘after’ 为每个下载的封装代码(默认为列表项)。如果您要更改这两个参数的值,请确保您设置大代码都进行过编码,如:将 < 替换为

&lt;

‘autop’ 可选值为 true 货 false,false 表示为不用 <p></p> 标签进行封装。

同样有效的使用方法:

[downloads]

[downloads query="limit=5&orderby=hits"]

[downloads query="limit=5&orderby=hits" format="2"]

[download query="limit=5&orderby=hits" wrap="" before="&lt;p&gt;" after="&lt;/p&gt;"]

显示一个特殊的下载页面

使用 [

download_page

] 这个 shortcode。请参阅“下载页”章节。

在模版中解析 shortcode

您知道还可以在文章意外的地方使用 shortcode 吗?只需要使用

do_shortcode()

函数执行您的 shortcode 即可。示例:

do_shortcode('[download id="1"]');

get_downloads()

模版函数

该函数将返回所有符合查询条件的下载。它只有一个包含查询字符串的参数。默认值如下:

'limit' => '', 'offset' => 0, 'vip' => 0 'category' => '', 'orderby' => 'id', 'order' => 'ASC'

和大多数 Wordpress 的函数一样,请将上面提到的属性使用 & 符号连接到一起来组成查询字符串。例如:

limit=5&orderby=hits&order=desc

limit

‘ 设置需要返回的记录数量,必须是整数。takes an integer and will return that many posts.

offset

‘ 设置开始返回的记录的索引号,索引号必须为整数,且从 0 开始(也就是说,0 表示第一条记录,1 表示第二条记录,以此类推)。

vip

‘ 可选值为:1 (true) 货 0 (false)。如果设置为 true,则只会显示用户有权访问的下载(非会员将无法看到仅会员才能下载的文件)。

category

‘ 设置需要返回下载文件的分类 ID,多个 ID 请用英文逗号分隔。

orderby

‘ 对所有下载进行排序。可选值:id, hits(下载次数), title(标题), date(日期), filename(文件名), 以及 random(随机)。最新添加:也可以使用 ‘meta’

meta_name

‘ 当 orderby 设置为 meta 时,将根据这里设置的字段进行排序。只有设置了所指定字段的下载文件才会显示。

order

‘ 可选值:‘ASC’ 为升序,‘DESC’ 为降序。

get_downloads() 返回一个数组,每个数组元素为包含下列属性的对象:

  • size
  • url
  • title
  • version
  • hits
  • image
  • desc
  • category
  • category_id
  • id
  • date
  • memberonly

使用方法:(输出最热门下载的列表)

$dl = get_downloads('limit=5&orderby=hits&order=desc');
 
if (!empty($dl)) {
    
echo '<ul class="downloadList">';
    
foreach($dl as $d) {
        
$date = date("jS M Y", strtotime($d->date));
        
echo '<li><a href="'.$d->url.'" title="'.__('Version',"wp-download_monitor").' '.$d->version.' '.__('downloaded',"wp-download_monitor").' '.$d->hits.' '.__('times',"wp-download_monitor").'" >'.$d->title.' ('.$d->hits.')</a></li>';
    
}
    
echo '</ul>';
}

Top

FAQ

My Downloads don’t work or the download page is not found/error 500’s, wtf?

Several reasons can cause this. First things first – check the plugin folders permissions. The folder and files should be readable – especially download.php so check! Also, avoid setting to 777 at all costs. Second, resave permalink settings – this can often cause hiccups. Finally, check the path to the download is correct by editing it – try entering the url directly into the address bar. If its not found, you cannot blame the plugin!

My hits are not showing up! Help?

Admin hits are not counted, log out and try! Also ensure that if you have set the ‘custom url’ option that the custom url does not actually match the physical location of the file.

I have wordpress installed in a sub directory and my downloads don’t work

Go to settings > misc in wordpress admin and check the ‘Store uploads in this folder’ setting is correct. Sometimes wordpress screws this up. You may also notice that normal uploads in wordpress (e.g. via the media panel) don’t work correctly either if this setting is wrong.

I get an ‘error saving to database error’. What’s happening?

The download tables may not exist. Use the option in Downloads > configuration > Recreate Download Database.

My member only downloads are corrupted/don’t work, why?

To hide the URL, member only downloads are forced by using PHP’s readfile function. If the download is hosted externally, or the server does not support it properly the download may be corrupted. To turn off forced downloading add the custom field ‘force’ to the download and set it to ‘0′.

I want my downloads to be parsed in a custom field using get_post_meta(), can I do this?

Wordpress does not have a filter I can hook into for this function, so to make this work wrap it in the relevant functions. For old style download links ([Download id not defined]) use

wp_dlm_parse_downloads()

else use

do_shortcode()

. For example:

echo do_shortcode(get_post_meta($post-&amp;gt;ID, 'Download', true));

What happened to the old tags?

They still exist – they are just no longer supported. See below.

The following (older) tags will work in your posts but are no longer supported (shortcodes are now preferred). These are mainly here for backward compatibility.

Output a download with a custom format:

Use the admin panel to define custom formats to output your links and then use

[download#id#format=id]

or just

[download#id]

if you set one as default.

Other output functions:

To show download links, use the following tags:

  1. Link/hits
    [download#id]
  2. Link w/o hits
    [download#id#nohits]
  3. URL only
    [download#id#url]
  4. Hits only -
    [download#id#hits]
  5. Link with image
    [download#id#image]
  6. Link/hits/filesize
    [download#id#size]
  7. Link/filesize
    [download#id#size#nohits]

There are a few other template tags to use in your wordpress templates. Replace ‘$no’ with the amount of downloads to show.

  1. Most downloaded –
    <?php wp_dlm_show_downloads(1,$no); ?>
  2. Most recent –
    <?php wp_dlm_show_downloads(2,$no); ?>
  3. Random –
    <?php wp_dlm_show_downloads(3,$no); ?>

Show all downloads:

Add the tag

[#show_downloads]

to a page.

Show downloads with category selector:

Add the tag

[#advanced_downloads]

to a page.

Show downloads in a single category:

Use

[download_cat#id]

replacing id with the id of the category.

Top

Download Page

I gave in. I was going to release this as a paid add-on, but I’ve changed my mind because I trust you guys to make donations to ensure support continues for this plugin. So here we go; the download page addon (as seen on this site in the ‘Downloads’ page) is now built into download monitor (version 3.1 +). The download page includes a sorting, pagination, and search function.

Usage

To create a download page, first create a wordpress page (or post) and insert the following shortcode:

[download_page]

Easy huh? But theres more. This shortcode has the following options:

  • base_heading_level (integer) – Category headings on the page are this level. Defaults to 3 (h3)
  • pop_count (integer) – How many popular downloads to show. Default is 4.
  • pop_cat_count (integer) – How many popular downloads to show per category. Default is 4.
  • show_uncategorized (integer) – Set to 1 (default) to show an uncategorized section, or 0 to hide it.
  • per_page (integer) – How many downloads to show per page. Default is 20.
  • format – ID of custom format to use.
  • exclude – Comma separated list of downloads to exclude from the listings.

So for example, to show 5 popular downloads I’d use:

[download_page pop_count="5"]

Easy peasy.

Customisation

So you want to customise the look? You can probably do that with CSS, either in your themes CSS file or by customising the styles.css which came with the plugin – this is found in download-monitor/page-addon/styles.css.

If for any reason the output looks unstyled completely, your version of wordpress may not support the way I added the styles.css file, so just paste the css code from that into your themes css file.

Configuring Download Data

The download page add-on is smart and uses your downloads custom fields to show the information. It lets you show an unlimited amount of custom fields like this:

  1. You add custom fields to a download, for example, ‘licence’ with value ‘Free (GNU General Public License)’.
  2. You then add a custom field called ‘include_fields’ and list the names of the fields to include on the download page separated by commas, e.g. tags,licence,wordpress-plugin-directory-page,documentation.

There are a few reserved custom field names you can use too:

  • post_id = add an id of an associated post to the download – the read more link on the download page will link to this post.
  • side_content = some content to show underneath the download link. On my site ive inserted some adsense code.
  • thumbnail = path to an image for the download’s thumbnail. 112×112 is ideal for this.
  • hide_download_button = Won’t show the download button. I’ve done this for my paid icon set because they cannot be downloaded from the site.
  • hide_hits = Hide hit count

Finally, remember I did not have to release this add-on for free, so please consider making a donation to ensure I continue developing download monitor in the future.


Top

相关日志

Did you enjoy this article? Share it or give it a bump!
1,025 Views

5 Comments on “Wordpress Download Monitor 中文帮助文档”

  • zzb wrote on 2010-03-22, 12:01 Reply to this comment

    但是咋没写批量导入文件的介绍呢,我看了英文好像也没有

  • Hpyer wrote on 2010-03-23, 18:36 Reply to this comment

    @zzb:
    目前是没有的。因为官网的这篇文章是在 3.3.3 版之前发布的,自然也不会包含批量导入功能的介绍。

  • 老耿 wrote on 2010-04-07, 18:53 Reply to this comment

    不错,收藏了。

  • Sevi wrote on 2010-05-30, 17:33 Reply to this comment

    关于“下 载 页”的中文说明可参考:
    http://witmax.cn/wordpress-download-monitor-usage.html

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Welcome to Hpyer 的未知空间

  哈咯~很高兴您能在浩瀚的网络中找到本站,虽然本站只是个博客,但是它却不仅仅是一个博客。在这里你将会了解到一些网页制作方面的知识,同时也可以获得一些实用的程序源码。但愿您在这次短暂的访问中可以有所收获。【了解更多】 【联系 Hpyer

Search

Search posts by Google engine. FROM:    

Advertisement