PHP, MySQL, CSS, XHTML, JavaScript
14. Jan. 2007
PHP / MySQL
Nå har jeg lagd mitt første komplette frittstående plugin til Wordpress. Hva den gjør? Den lar deg opprette linker til filer og holde rede på hvor mange ganger noen har trykt på linken. Pluginet kommer med en engelsk readme foreløpig. Etterhvert kommer jeg nok til å oversette readme til norsk også, men til da får det holde med engelsk. Nedenfor finner du denne readme-en. Om noen spørsmål skulle dukke opp, bruk e-post eller kommentarfeltene.
Download wp-dlCount-plugin.zip
Lastet ned 1081 ganger.
This version is the first of this plugin. It's running on my own blog, and has been tested for some days. The version running is 0.9.5.
There are no special requirements, except for running WordPress and you have to be able to create two tables in the wordpress-database. The two tables are written down below.
The plugin uses the wordpress-database, but you'll have to create the tables yourself. You'll need two of them. One to contain the files, and the other to count the downloads and som statistics. Their names are: wp_dlcount and wp_dlfile, relativly with what your table_prefix in wordpress is!
SQL-Queries:
So, that's all the creating you need actually, except copying the files over to the plugin directory.
So after you have created the those two tables in your wordpress-database, you would also need to copy the files into your plugin dir, and activate it in your wp-admin-panel.
* Copy the whole download_count directory into /wp-content/plugins/
Now you can see under Options in the adminpanel, a link called Download Count. Press it and get a page up. There will be no list there at this point, since no files are added. This will come under USAGE.
Now we will go through how to add files, and where to put the files.
There are three "codes" to use with this plugin. One to make link to a file and add the file to the database, one other to show how many is downloaded, and the last one to see a list of downloadable files with statistics.
WARNING: ALL these "codes" must be used within a post.
Syntax:
CODE-SYNTAX => Description
[ link:FILE] => Add file and get the link.
[ print_dl_list] => Get the list of all files, and the count
[ downloaded:FILE] => Get the count of downloaded-times.
(Note: No space between [ and the rest. Just to avoid the plugin to kick in, on this page.)
!!IMPORTANT!!
Now, there are two ways to do it with the download path:
#1 Have a static folder witch has all your downloadable files. And use only the basename of the file in both syntaxes.
#2 Set the $filedir IN THE CONSTRUCTOR of dlCount-plugin.php to this:
$this->filedir = '';
Now you have no static folder and can write your own path. Like this: [ link:./my/path/file.zip]
WARNING: If you're using method #2, you will get an error if you
have only / first, with no "." before it. So please do use ./ if you
use something at all.
My file email.zip has been downloaded [ downloaded:email.zip] times.
You can also download it:
[ link:email.zip]
Here is all my files, available for download:
[ print_dl_list]
This plugin is written by Mikael Brevik, and all rights are reserved for me, and me only! If you wish to edit this script, you should contanct
me, the author, at: mikaelb@mikaelb.net.
If you want to link back to my site (http://mikaelb.net) that's cool with me.
Have a fine day!
Innlegget ble postet 14.01.07 03:47 og ligger under kategorien PHP / MySQL. Du kan abonnere på kommentarene ved å bruke RSS 2.0 feed. Du kan legge til kommenter, eller trackback fra din blogg/side.
Ser bra ut, har dog ikke fått testet det ut enda.
Men er det lov å spørre hvilken syntax highlight plugin du bruker?
Hans-Kristian skrev dette 14 Januar, 2007 13:03 - Sitér
Hepp!
Det kan du selvfølgelig gjøre...
Foreløpig bruker jeg iG:Syntax Hiliter Plugin, men spørs om jeg kommer til å lage min egen en dag. Noe jeg ikke liker helt ved highlightern. Blant annet at instillingene resetter seg hele tiden.
Mikael Brevik skrev dette 14 Januar, 2007 15:19 - Sitér
you say it only works in posts... does it work with pages? all my filles are set up in pages.
skridge skrev dette 31 Januar, 2007 04:40 - Sitér
Hey!
Yes, it also works in pages. All input submittet by post or pages.
Mikael Brevik skrev dette 31 Januar, 2007 14:10 - Sitér
dude it is a good plugin
but in my wordpress it doesnt work!!!
i did what you said above all the thing
i have a static dir.
but it doesnt work!!
it says there is not such a file but it is?
i cant undertake the situation dude??
BlueDeviL skrev dette 12 April, 2007 16:09 - Sitér
An e-mail is sent, and we'll find a answare for this.
Two possible errors:
- Wrong path.
- MySQL error.
Mikael Brevik skrev dette 12 April, 2007 18:51 - Sitér
Merk at det ikke skal være noe mellomrom imellom første hakeparentes ( [ ) som det er vist i Readme.txt og guiden her:
[ link:FILE] => Add file and get the link.
[ print_dl_list] => Get the list of all files, and the count
[ downloaded:FILE] => Get the count of downloaded-times.
Fant ikke feilen med en gang, men det var jo selvsagt logisk at det ikke skal finnes noe mellomrom.
English: Notice that's there's not supposed to be any space between the first [ and the rest of the code-syntax.
Magnus Gule skrev dette 24 April, 2007 23:02 - Sitér
Vell, det burde kanskje vært nevnt at det ikke skal være noe mellomrom nei. Det ble skrevet i bloggen for å unngå at plugin skal slå seg inn. Men, ja. Kan føre opp det i teksten nå.
Mikael Brevik skrev dette 25 April, 2007 14:55 - Sitér
[...] Visit [...]
WP Plugins DB » Blog Archive » Download Count skrev dette 20 Mai, 2007 09:57 - Sitér
Hi, I'm having the same problem as BlueDevil... can you help? :)
Ian skrev dette 11 Juni, 2007 20:47 - Sitér
I replyed your e-mail, and hope it's working out for you.
To all: Remember to check the directory configuration.
Mikael Brevik skrev dette 12 Juni, 2007 03:04 - Sitér
I am looking to do this as a self contained function to use outside of WordPress. What would be the function to count the times a zip file is accessed?
bonefied skrev dette 20 September, 2007 15:22 - Sitér
Hey,
If you look beneeth the class you'll see
If you change that to something like:
And it'll work without WP. Might need some other mods. If so, contact me and I'll help you out.
Good Luck!
Mikael Brevik skrev dette 20 September, 2007 19:30 - Sitér
Good post.
Malissa skrev dette 27 Oktober, 2008 16:50 - Sitér
Ready to argue with the themes of education-all. All the same, you can very well write about it
Roman skrev dette 6 November, 2008 05:58 - Sitér