---------------------------- WCDDL Module Creation How-To ---------------------------- This small readme will tell you exactly how to create your own modules for WCDDL. Requirements: - PHP Knowledge - Basic SQL Knowledge - General HTML Knowledge Ok, now the actual How-To... All modules in WCDDL are executed via a special KEYWORD. For example, the built-in Recent Searches module uses "RECENTS". So wherever "%RECENTS%" is placed in the PHP file(s), recent searches will be displayed. Although it may seem your module has to display something, it actually doesn't! You will see further on why. Step by step, here is an example module tutorial: ---------------------------- Step 1 ---------------------------- Create a function in funcs.php OR create a file named "wcddl_{MODULE NAME HERE}.php" (replace the "{MODULE NAME HERE}" text). If you choose to create a file, you must then create a function in that file named the same as the module name. So in this example, let's say we create "wcddl_jmz.php". In this file we then need to do: Thats step 1 complete. ---------------------------- Step 2 ---------------------------- Code your function! In this example we will use the following: function jmz() { $example = "w00t for jmz!"; return $example; } NOTE: To display ANYTHING you MUST return it, DO NOT echo/print it. TIP: There are many preset variables you may use, they are all listed at the bottom of this file. ---------------------------- Step 3 ---------------------------- Create a readme file and tell the user where to place your function. For example, with the function in this tutorial, they would place: %jmz% Anywhere in any wcddl php file to display "w00t for jmz!" ---------------------------- General Notes ---------------------------- - If you create a module file, it MUST be in the same folder as WCDDL - We highly recommend that you include a readme - If additional SQL tables are required, CREATE AN INSTALL FILE TO EXECUTE THE SQL! - If you create a module file, it MUST be named with the prefix, "wcddl_" - A module file's name MUST MATCH the function it contains (e.g. wcddl_woo.php and function woo() { ) - DO NOT create an SQL connection in a module, one already exists ---------------------------- Preset Variables ---------------------------- Name | Description $limit | The number of rows to display when running any query which returns many rows (REQUIRED when using pagination) $page | The current page number $allowed_types | The types of downloads which are allowed (Array) $blackorwhite | Blacklist or whitelist? ("black" or "white") $search_type | Narrow or wide search? $q | The search query (what a user has searched for) $type | The current set download type (user-set) $id | The id which is currently set (user-set) $go | The go variable, used to determine which page/function to show/run $fetch_downloads| If set, the current page will execute a process which fetches downloads (uses $q and $type if they are set) $fetch_order | Change the order in which downloads are displayed (e.g. "id DESC") $downloads | The currently "fetched" downloads (Array) $max_pages | The maximum pages available, based on the $fetch_downloads query $is_submit | If true, triggers the submission recieving process (For submit.php) $download_info | If true, fetches download information based on the current value of $id $download_site | If true, fetches site information for the current download (To be used with $download_info) $download_views | If true, the view field of a download increases everytime it is viewed $download | If $download_info is set, $download is the array of details for the current download ID ($id) $is_admin | If set, the current page is treated as an admin page and will require login and/or an admin session ---------------------------- Preset Functions ---------------------------- These functions may be used in any module but only when and if needed Name | Description mapit($array,$funcs) | Apply any given functions to $array, e.g. mapit($somearray,array("stripslashes","strrev")), this will stripslashes and reverse each value in the array $somearray rate_form() | Display the rate form and run the rate process if it is submitted (MUST BE USED WITH $id)