Wordpress installation and configuration: Difference between revisions
mNo edit summary |
|||
(34 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
[http://wordpress.org/ Wordpress] (WP) is quote {{quotation|a state-of-the-art publishing platform with a focus on aesthetics, web standards, and usability. WordPress is both free and priceless at the same time. More simply, WordPress is what you use when you want to work with your blogging software, not fight it.}} (retrieved on Jan 19 2010). | [http://wordpress.org/ Wordpress] (WP) is quote {{quotation|a state-of-the-art publishing platform with a focus on aesthetics, web standards, and usability. WordPress is both free and priceless at the same time. More simply, WordPress is what you use when you want to work with your blogging software, not fight it.}} (retrieved on Jan 19 2010). | ||
This is a short installation and configuration manual. Please, | This is a '''very outdated''' short installation and configuration manual which may be update in some far future. Please, read the fine official [http://codex.wordpress.org/Installing_WordPress Installing Wordpress]. The only reason I created this article, was to to have a short piece I could use with a projector in a ''web applications class'' and give out as handout. Personally I don't use Wordpress, but I think that it is one of the best systems to get started with the world of [[CMS]]s - [[User:Daniel K. Schneider|Daniel K. Schneider]] 16:31, 19 January 2010 (UTC)/ 15:43, 13 September 2016 (CEST)~ | ||
== Installation == | == Installation == | ||
(as of Jan 2010, should be ok in spirit in Jan 2011) | |||
Installation includes four fairly easy steps: | Installation includes four fairly easy steps: | ||
Line 52: | Line 54: | ||
* database name = blog | * database name = blog | ||
* database user name = blog | * database user name = blog | ||
* password = | * password = ''thePasswordYouEnteredTwice'' | ||
Remark: Do not confound the mysql user and password with the wordpress administrator user and password that you will have to create later. The mysql user will be used by the PHP scripts of the WP software. | Remark: Do not confound the mysql user and password with the wordpress administrator user and password that you will have to create later. The mysql user will be used by the PHP scripts of the WP software. | ||
Line 61: | Line 63: | ||
# Download the WordPress package from http://wordpress.org/download/ | # Download the WordPress package from http://wordpress.org/download/ | ||
# | # Unzip the package to your hard drive. You will see a directory called ''wordpress'' | ||
# If you would your site's URL to be something other than http://xxx/wordpress, rename the ''wordpress'' directory. For example, if you wish to have a URL on your server like http://xxxx/blog, then ''rename'' the wordpress directory to ''blog''. | |||
# If you wish to have a URL on your server like http://xxxx/blog, then ''rename'' the wordpress directory to ''blog'' | # Transfer this directory to the web server tree, e.g. via FTP to a provider, to a local "www" directory or somewhere on your local area network. If you happen to use a [[WAMP]] system, the directory might typicall be something like ''c:\....\www'', e.g. ''c:\servers\mowes\www'' or ''c:\wamp\www'' | ||
# | |||
; Run the installer script | |||
(1) Access wp-admin/install.php from your web browser. E.g. on your local test server the URL might be something like: | |||
http://localhost/blog/ | |||
You actually will be redirected to the following page: | |||
http://localhost/blog/wp-admin/install.php | |||
If you placed the WordPress files in a subdirectory called blog, for example, you should visit: http://example.com/blog/wp-admin/install.php | |||
If WordPress can’t find the wp-config.php file, it will tell you and offer to try to create and edit the file itself. WordPress will ask you the database details and write them to a new wp-config.php file. If this works, you can go ahead with the installation; otherwise, go back and create, edit, and upload the wp-config.php file yourself (see below). | |||
[[File:Wordpress-install-script.png|Wordpress' install script (v47)]] | |||
Remark: If you can't see the page or get an error message, please fix the syntax mistakes you just made before in the configuration file. If you cannot find the mistake by yourself, look at the server log. E.g. open file ''c:\...\apache2\logs\error.log''. Else, ask a local expert to help. | |||
(2) The script will then ask you to provide a name for the blog and an email address (the email address can bogus for a test system) | |||
* Make absolutely sure to copy/paste the generated password to a safe place !! | |||
(3) Log in | |||
* Change immediately the password to a complicated one that you can remember well. | |||
.... enjoy :) | |||
; Edit the configuration file | ; Edit the configuration file | ||
Line 104: | Line 127: | ||
* For programmers who don't know PHP: ''define'' is an instruction that just defines a named constant at runtime. | * For programmers who don't know PHP: ''define'' is an instruction that just defines a named constant at runtime. | ||
* If you only own a single database and already have a wordpress installed, you also need to change the prefix towards the end of the configuration file. Else two different WP installations will use the same tables (very messy!) | * If you only own a single database and already have a wordpress installed, you also need to change the prefix towards the end of the configuration file. Else two different WP installations will use the same tables (very messy!) | ||
<source language="php"> | |||
$table_prefix = 'wp_'; | |||
</source> | |||
So double check what you did and then save the file. | So double check what you did and then save the file. | ||
== Configuration == | == Configuration == | ||
Line 233: | Line 242: | ||
* Create two users, each beloging to a different category. | * Create two users, each beloging to a different category. | ||
* Install plugins. This is really easy with Wordpress (just try) | * Install plugins. This is really easy with Wordpress (just try) | ||
== Updating Wordpress == | |||
For security reasons, it is crucial to keep your WordPress site up to date. To update your site, select the ''Updates'' menu item from the sidebar and follow the instructions on the update page. | |||
[[File:Wordpress-updates-notification.png|WordPress sidebar updates notification]] | |||
If your server requires an SSH or SFTP connection, you might get an error message during the update process. To connect to your server, you'll first need to install a plugin such as [https://wordpress.org/plugins/ssh-sftp-updater-support/ SSH SFTP Updater Support] to enable those types of connection. | |||
== Plugins == | |||
[[image:wordpress-2-9x-manage-plugins.png|thumb|400px|right|Wordpress 2.9.2 Manage plugins tool]] | |||
'''Finding plugins''' | |||
Plugins can extend WordPress to do almost anything you can imagine. In the official [http://wordpress.org/extend/plugins/ Wordpress plugin directory] you can find, download, rate, and comment on all the best plugins the WordPress community has to offer. | |||
'''Installing plugins''' | |||
To install a plugin dezip into the wordpress '''/wp-content/plugins''' directory. Plugin should be in a subdirectory. Alternatively, you may directly search and install plugins from the Wordpress admin interface (recommended for beginners). Click on '''Plugins''' and then "Add New". | |||
To activate a plugin, open the administration interface and click on the '''Plugins tab''' to open '''Manage plugins''' tool. You will see a list of plugins. Click and "Activate". | |||
'''Configuring a plugin''' | |||
Each plugin comes with a different set of tools. Some also include help, otherwise you will have to find help on the plugin web site. | |||
=== Headers and Footers === | |||
The [https://wordpress.org/plugins/insert-headers-and-footers/ Insert Header and Footers] plugin allows easily some types of custom HTML code. Quote (10/2020) "Insert Headers and Footers is a simple plugin that lets you insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site header and footer. No need to edit your theme files!". This plugin, as of oct. 2020 has over 1 Mio installs and therefore should be safe to use. | |||
Once installed you can add code in <code>Settings -> Insert Headers and Footers</code> | |||
'''Adding google fonts''' | |||
[https://www.wpbeginner.com/wp-themes/how-to-add-custom-fonts-in-wordpress/ How to Add Custom Fonts in WordPress] from Wpbeginner (March 12th, 2020 when consulted on oct 2020) describes several methods. We chose the one that uses this plugin: | |||
1) Go to [https://fonts.google.com/ google fonts] | |||
2) Pick a font. If you know the name, use search e.g. [https://fonts.google.com/specimen/Barlow?query=barlow Barlow]. The nclick on a result. You should see a list of styles | |||
3) Pick a style variant in the list. E.g. for Barlow I took "regular" which also will include thin, bold and very bold. | |||
<source lang="HTML"> | |||
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;700;900&display=swap" rel="stylesheet"> | |||
</source> | |||
4) In WordPress, open <code>Settings -> Insert Headers and Footers</code> | |||
Copy/paste the link from the Google page (i.e. the code above) into the "Scripts in Header" section. | |||
5) Use the fonts | |||
Open the theme: <code>Appearance -> Themes</code> Select the active theme and click on Customize. | |||
Open Additional CSS, and add CSS rules, e.g. | |||
<source lang="CSS"> | |||
.h1 {font-family: 'Barlow', Arial, sans-serif; } | |||
</source> | |||
We suggest adding fallback fonts, in case the plugin stops working or something else goes wrong. | |||
=== Forms builders === | |||
Below are plugins for creation of embedded "mini-databases". None of the free ones we examined is easy to use. Form building is fairly easy, but the main difficulty is to display the data. - [[User:Daniel K. Schneider|Daniel K. Schneider]] 18:31, 21 February 2010 (UTC). | |||
'''Formidable''' | |||
[http://wordpress.org/extend/plugins/formidable/ Formidable] allows to quickly and easily build forms with a simple drag-and-drop interface. However, if you want a tool for easy display of results, you will have to buy the commercial version. | |||
'''TDO Mini Forms''' | |||
[http://wordpress.org/extend/plugins/tdo-mini-forms/ TDO Mini Forms]. {{quotation|This plugin allows you to add highly customisable forms that work with your Wordpress Theme to your website that allows non-registered users and/or subscribers (also configurable) to submit and edit posts and pages}}, retrieved 19:48, 18 February 2010 (UTC). | |||
* Creation of the [http://indilean.com/contribute/ Indilean.com user contribution form] with TDO Mini Forms is explained in [http://sustainableonlinesolutions.com/wordpress-wiki this article and video] | |||
'''WordPress Form Creator''' | |||
[http://wordpress.org/extend/plugins/wp-form-creator/ WordPress Form Creator] {{quotation|provides blog website owners with a truly easy to manage easy to configure forms solution for WordPress or WordPress CMS sites. In this release you can drag and drop the form elements to the generator page to create your forms.}}, retrieved 19:48, 18 February 2010 (UTC). | |||
'''Supple Forms''' | |||
[http://wordpress.org/extend/plugins/supple-forms/ Supple Forms] {{quotation|makes it easy to create a custom meta box or write panel to enter data while adding or editing posts and pages. Supple Forms allows you to easily format and insert your data into posts by using shortcodes and HTML snippets.}}, retrieved 19:48, 18 February 2010 (UTC). | |||
'''Gravity Forms''' | |||
[http://www.gravityforms.com/ Gravity forms] (fully commercial) | |||
'''Cforms''' | |||
[http://www.deliciousdays.com/cforms-plugin/ cforms] is {{quotation|a powerful and feature rich form plugin for Wordpress}}. Display of collected data has to be progreammed manually. Free/GPL. | |||
* Cforms seems to have a path problem when migrating. See the [http://wordpress.org/extend/plugins/advanced-edit-cforms/ Advanced Edit Cforms] | |||
=== Using the CformsII plugin to collect and display data === | |||
'''Remarks''': | |||
* The Plugin control panel in WP includes a help file. Read it ! | |||
* Disclaimer: I never use Wordpress (and don't know anything about it), but I sometimes use Wordpress to teach about [[CMS]]/CMFs. If you know an easier solution to create data collection forms, please add it here - [[User:Daniel K. Schneider|Daniel K. Schneider]] 20:50, 21 February 2010 (UTC). | |||
(0) '''Installation''' | |||
* Download the cformsII extension from [http://www.deliciousdays.com/cforms-plugin/ deliciousdays.com] | |||
* Dezip in directory wordpress/'''wp-content/plugins/''' | |||
You now should have a ''cforms'' directory inside the plugins directory. | |||
* Click ''Plugins'' in the WP Dashboard and activate the plugin (as explained above). | |||
(1) '''Creating a form''' | |||
Creating a form with CformsII is fairly easy and we will not explain much here: | |||
* Click on cformsII in the WP Dashboard | |||
* Add new form (in the Admin Actions menu you find on top right) | |||
* Click on '''update settings''' each time you make a change. | |||
* Modify or remove existing input fields. Do not remove the Fieldset field, but you may rename it. | |||
* **Add** as many new fields you like. Select the right position or move the field later. | |||
If you want to learn form creation for real, read the '''help''' (available in the cformsII controls of the wordpress dashboard ....) | |||
(2) '''Using the form''' | |||
We suggest to retrieve user data with a page. Create a new page. In the editor, you now may insert cforms by clicking on the newly installed cforms button in the edit bar (Visual edit mode). Else, if you prefer manual HTML editing, insert: | |||
<source lang="xml"> <!--cforms name="COAP"--></source> | |||
(3) '''To collect data to a database''': | |||
* Click on '''global settings''' in the cformsII control | |||
* Click on "Database Input Tracking" | |||
* Tick "Enable Input Tracking". | |||
Don't forget to click on "Update Settings" ! You may check MySQL whether there are two new tables: ''wp_cformsdata'' and ''wp_cformssubmissions''. | |||
(4) '''Displaying results''' | |||
To display results, you need to program. This seems to be a general "feature" of free Wordpress extensions.... | |||
[[image:wordpress-select-page-template.png|frame|right|Select page template for a given Wordpress page]] | |||
A first solution is to create a new [http://codex.wordpress.org/Pages#Page_Templates page template] and modify it to deal with cformsII data. In wordpress, {{quotation|Individual pages can be set to use a specific custom Page Template (a PHP template file, e.g., snarfer.php) you create within your Theme (see Creating your own Page Templates below on how to create a custom template). This new Page Template will then override the default page.php Page Template included with your Theme.}} (retrieved 19:02, 21 February 2010 (UTC)). | |||
All you need to do is to add some php code to display the table into the code. | |||
Then create a new page and use this new template. In the ''Edit Page'' interface, under ''Attributes'' (right column) you can change the the Template as shown in the picture to the right. | |||
Below is a simple solution for displaying database contents for a given Cform. The CformsII API defines the following function: | |||
<source lang="php"> | |||
get_cforms_entries( $fname, $from, $to, $sort, $limit ,$sortdir ) | |||
</source> | |||
See the help for an explanation. All parameters are optional and we will just use the first one, i.e. $fname, to provide the form name. | |||
Now, copy file ''wp-content/themes/default/page.php'' to ''wp-content/themes/default/cforms-page.php'' and modify it like this: | |||
<source lang="php"> | |||
<?php | |||
/* | |||
Template Name: cforms-template | |||
*/ | |||
?> | |||
<?php | |||
/** | |||
* @package WordPress | |||
* @subpackage Default_Theme | |||
*/ | |||
get_header(); ?> | |||
<div id="content" class="narrowcolumn" role="main"> | |||
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> | |||
<div class="post" id="post-<?php the_ID(); ?>"> | |||
<h2><?php the_title(); ?></h2> | |||
<div class="entry"> | |||
<?php | |||
// --------------------------------- Start cforms-modif | |||
// all data from COAP form | |||
$c_array = get_cforms_entries('COAP'); | |||
/* Uncomment the next three lines to debug or see what kind of data you get | |||
echo "DEBUG c_array:<pre>"; | |||
print_r ($c_array); | |||
echo "</pre>"; */ | |||
$cform_output = '<table border="1">'; | |||
$cform_output .= "<tr>"; | |||
$cform_output .= '<th>Problem</th><th>Name</th><th>Email</th><th>Website</th><th>Message</th>'; | |||
$cform_output .= "</tr>"; | |||
foreach( $c_array as $e ){ | |||
$cform_output .= "<tr>"; | |||
$cform_output .= '<td>' . $e['data']['Problem'] . '</td>'; | |||
$cform_output .= '<td>' . $e['data']['Your Name'] . '</td>'; | |||
$cform_output .= '<td>' . $e['data']['Email'] . '</td>'; | |||
$cform_url = $e['data']['Website']; | |||
$cform_output .= '<td>' . '<a href="' .$cform_url. '">'. $cform_url . '</a></td>'; | |||
$cform_output .= '<td>' . $e['data']['Message'] . '</td>'; | |||
$cform_output .= "</tr>"; | |||
} | |||
$cform_output .= "</table>"; | |||
echo $cform_output; | |||
// --------------------------------- End cforms-modif | |||
?> | |||
<?php the_content('<p class="serif">Read the rest of this page »</p>'); | |||
?> | |||
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> | |||
</div> | |||
</div> | |||
<?php endwhile; endif; ?> | |||
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> | |||
<?php comments_template(); ?> | |||
</div> | |||
<?php get_sidebar(); ?> | |||
<?php get_footer(); ?> | |||
</source> | |||
Alternatively you also could install the [http://bluesome.net/post/2005/08/18/50/ Exec-PHP] plugin from or a similar tool and activate it. Then just include the loop from the above code. However, this kind of feature is quite a security risk. | |||
== Database structure == | |||
Since we use Wordpress to teach about web databases (see e.g. the SQL and MySQL tutorial]], we include two database entity relationship diagrams (WP 2.7) and a dump of a relatively fresh Wordpress 2.9.1 installation below. | |||
{{quotation|The diagram below provides a visual overview of the Wordpress database and the relations between the tables (WP Version 2.5+) created during the WordPress standard installation. The Table Overview below includes additional details on the tables and columns.}} ([http://codex.wordpress.org/Database_Description Database Description], Wordpress Codex, retrieved 20:46, 26 January 2010 (UTC). | |||
[[image:WP_27_dbsERD.png|thumb|none|800px|Wordpress 2.7 Entity-relationship diagram. Source: [http://codex.wordpress.org/Database_Description Database Description]]] | |||
Jaymin Kapish in his [http://www.jayminkapish.com/ blog] published [http://www.jayminkapish.com/2008/01/18/wordpress-database-schema/ alternative database diagrams for several wordpress versions], of which we reproduce the [http://blog.kapish.co.in/wp-content/uploads/2009/03/wp_2.7.png 2.7 version here] and that you also may enlarge. | |||
[[image:wp_2.7-jayminkapish.png|none|800px|right|Wordpress 2.7 Database Schema by Jaymin Kapish]] | |||
As you can see, Jaymin regroups various tables according to what kind of thing they describe. E.g. Roughly speaking, there are 4 tables to talk about Posts. He also uses a different notation for links. A 1-N relationship is shown as "X to Y" in the label. Arrows go from table to table (and not from field to field). | |||
The following dump was made from an mostly unused WP demo installation of WP 2.8, automatically upgraded to 2.9.1. In addition, the dump includes four tables that belong to an extension called "formidable". | |||
<source lang="sql"> | |||
-- phpMyAdmin SQL Dump | |||
-- version 3.1.2 | |||
-- http://www.phpmyadmin.net | |||
-- | |||
-- Host: localhost | |||
-- Generation Time: Jan 26, 2010 at 09:39 PM | |||
-- Server version: 5.1.35 | |||
-- PHP Version: 5.3.0 | |||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | |||
-- | |||
-- Database: 'wordpress' | |||
-- | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_commentmeta' | |||
-- | |||
CREATE TABLE wp_commentmeta ( | |||
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
comment_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
meta_key varchar(255) DEFAULT NULL, | |||
meta_value longtext, | |||
PRIMARY KEY (meta_id), | |||
KEY comment_id (comment_id), | |||
KEY meta_key (meta_key) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_comments' | |||
-- | |||
CREATE TABLE wp_comments ( | |||
comment_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
comment_post_ID bigint(20) unsigned NOT NULL DEFAULT '0', | |||
comment_author tinytext NOT NULL, | |||
comment_author_email varchar(100) NOT NULL DEFAULT '', | |||
comment_author_url varchar(200) NOT NULL DEFAULT '', | |||
comment_author_IP varchar(100) NOT NULL DEFAULT '', | |||
comment_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
comment_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
comment_content text NOT NULL, | |||
comment_karma int(11) NOT NULL DEFAULT '0', | |||
comment_approved varchar(20) NOT NULL DEFAULT '1', | |||
comment_agent varchar(255) NOT NULL DEFAULT '', | |||
comment_type varchar(20) NOT NULL DEFAULT '', | |||
comment_parent bigint(20) unsigned NOT NULL DEFAULT '0', | |||
user_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
PRIMARY KEY (comment_ID), | |||
KEY comment_approved (comment_approved), | |||
KEY comment_post_ID (comment_post_ID), | |||
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt), | |||
KEY comment_date_gmt (comment_date_gmt) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_links' | |||
-- | |||
CREATE TABLE wp_links ( | |||
link_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
link_url varchar(255) NOT NULL DEFAULT '', | |||
link_name varchar(255) NOT NULL DEFAULT '', | |||
link_image varchar(255) NOT NULL DEFAULT '', | |||
link_target varchar(25) NOT NULL DEFAULT '', | |||
link_description varchar(255) NOT NULL DEFAULT '', | |||
link_visible varchar(20) NOT NULL DEFAULT 'Y', | |||
link_owner bigint(20) unsigned NOT NULL DEFAULT '1', | |||
link_rating int(11) NOT NULL DEFAULT '0', | |||
link_updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
link_rel varchar(255) NOT NULL DEFAULT '', | |||
link_notes mediumtext NOT NULL, | |||
link_rss varchar(255) NOT NULL DEFAULT '', | |||
PRIMARY KEY (link_id), | |||
KEY link_visible (link_visible) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_mngl_board_comments' | |||
-- | |||
CREATE TABLE wp_mngl_board_comments ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
author_id int(11) NOT NULL, | |||
message text, | |||
board_post_id int(11) NOT NULL, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY author_id (author_id), | |||
KEY board_post_id (board_post_id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_mngl_board_posts' | |||
-- | |||
CREATE TABLE wp_mngl_board_posts ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
owner_id int(11) NOT NULL, | |||
author_id int(11) NOT NULL, | |||
message text, | |||
`type` varchar(255) DEFAULT 'post', | |||
`source` varchar(255) DEFAULT NULL, | |||
visibility varchar(255) DEFAULT 'public', | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY owner_id (owner_id), | |||
KEY author_id (author_id), | |||
KEY `type` (`type`), | |||
KEY `source` (`source`), | |||
KEY visibility (visibility) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_mngl_friends' | |||
-- | |||
CREATE TABLE wp_mngl_friends ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
user_id int(11) NOT NULL, | |||
friend_id int(11) NOT NULL, | |||
`status` varchar(255) DEFAULT NULL, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY user_id (user_id), | |||
KEY friend_id (friend_id), | |||
KEY `status` (`status`) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_mngl_friend_requests' | |||
-- | |||
CREATE TABLE wp_mngl_friend_requests ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
user_id int(11) NOT NULL, | |||
friend_id int(11) NOT NULL, | |||
friend_record_a_id int(11) NOT NULL, | |||
friend_record_b_id int(11) NOT NULL, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY user_id (user_id), | |||
KEY friend_id (friend_id), | |||
KEY friend_record_a_id (friend_record_a_id), | |||
KEY friend_record_b_id (friend_record_b_id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_options' | |||
-- | |||
CREATE TABLE wp_options ( | |||
option_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
blog_id int(11) NOT NULL DEFAULT '0', | |||
option_name varchar(64) NOT NULL DEFAULT '', | |||
option_value longtext NOT NULL, | |||
autoload varchar(20) NOT NULL DEFAULT 'yes', | |||
PRIMARY KEY (option_id), | |||
UNIQUE KEY option_name (option_name) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=220 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_postmeta' | |||
-- | |||
CREATE TABLE wp_postmeta ( | |||
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
post_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
meta_key varchar(255) DEFAULT NULL, | |||
meta_value longtext, | |||
PRIMARY KEY (meta_id), | |||
KEY post_id (post_id), | |||
KEY meta_key (meta_key) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_posts' | |||
-- | |||
CREATE TABLE wp_posts ( | |||
ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
post_author bigint(20) unsigned NOT NULL DEFAULT '0', | |||
post_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
post_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
post_content longtext NOT NULL, | |||
post_title text NOT NULL, | |||
post_excerpt text NOT NULL, | |||
post_status varchar(20) NOT NULL DEFAULT 'publish', | |||
comment_status varchar(20) NOT NULL DEFAULT 'open', | |||
ping_status varchar(20) NOT NULL DEFAULT 'open', | |||
post_password varchar(20) NOT NULL DEFAULT '', | |||
post_name varchar(200) NOT NULL DEFAULT '', | |||
to_ping text NOT NULL, | |||
pinged text NOT NULL, | |||
post_modified datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
post_modified_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
post_content_filtered text NOT NULL, | |||
post_parent bigint(20) unsigned NOT NULL DEFAULT '0', | |||
guid varchar(255) NOT NULL DEFAULT '', | |||
menu_order int(11) NOT NULL DEFAULT '0', | |||
post_type varchar(20) NOT NULL DEFAULT 'post', | |||
post_mime_type varchar(100) NOT NULL DEFAULT '', | |||
comment_count bigint(20) NOT NULL DEFAULT '0', | |||
PRIMARY KEY (ID), | |||
KEY post_name (post_name), | |||
KEY type_status_date (post_type,post_status,post_date,ID), | |||
KEY post_parent (post_parent) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_terms' | |||
-- | |||
CREATE TABLE wp_terms ( | |||
term_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
`name` varchar(200) NOT NULL DEFAULT '', | |||
slug varchar(200) NOT NULL DEFAULT '', | |||
term_group bigint(10) NOT NULL DEFAULT '0', | |||
PRIMARY KEY (term_id), | |||
UNIQUE KEY slug (slug), | |||
KEY `name` (`name`) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_term_relationships' | |||
-- | |||
CREATE TABLE wp_term_relationships ( | |||
object_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
term_taxonomy_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
term_order int(11) NOT NULL DEFAULT '0', | |||
PRIMARY KEY (object_id,term_taxonomy_id), | |||
KEY term_taxonomy_id (term_taxonomy_id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_term_taxonomy' | |||
-- | |||
CREATE TABLE wp_term_taxonomy ( | |||
term_taxonomy_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
term_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
taxonomy varchar(32) NOT NULL DEFAULT '', | |||
description longtext NOT NULL, | |||
parent bigint(20) unsigned NOT NULL DEFAULT '0', | |||
count bigint(20) NOT NULL DEFAULT '0', | |||
PRIMARY KEY (term_taxonomy_id), | |||
UNIQUE KEY term_id_taxonomy (term_id,taxonomy), | |||
KEY taxonomy (taxonomy) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_usermeta' | |||
-- | |||
CREATE TABLE wp_usermeta ( | |||
umeta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
user_id bigint(20) unsigned NOT NULL DEFAULT '0', | |||
meta_key varchar(255) DEFAULT NULL, | |||
meta_value longtext, | |||
PRIMARY KEY (umeta_id), | |||
KEY user_id (user_id), | |||
KEY meta_key (meta_key) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_users' | |||
-- | |||
CREATE TABLE wp_users ( | |||
ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |||
user_login varchar(60) NOT NULL DEFAULT '', | |||
user_pass varchar(64) NOT NULL DEFAULT '', | |||
user_nicename varchar(50) NOT NULL DEFAULT '', | |||
user_email varchar(100) NOT NULL DEFAULT '', | |||
user_url varchar(100) NOT NULL DEFAULT '', | |||
user_registered datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |||
user_activation_key varchar(60) NOT NULL DEFAULT '', | |||
user_status int(11) NOT NULL DEFAULT '0', | |||
display_name varchar(250) NOT NULL DEFAULT '', | |||
PRIMARY KEY (ID), | |||
KEY user_login_key (user_login), | |||
KEY user_nicename (user_nicename) | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; | |||
</source> | |||
Structure of formidable, a form management tools plugin | |||
<source lang="sql"> | |||
-- | |||
-- Table structure for table 'wp_frm_fields' | |||
-- | |||
CREATE TABLE wp_frm_fields ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
field_key varchar(255) DEFAULT NULL, | |||
`name` varchar(255) DEFAULT NULL, | |||
description text, | |||
`type` text, | |||
default_value longtext, | |||
`options` longtext, | |||
field_order int(11) DEFAULT '0', | |||
required int(1) DEFAULT NULL, | |||
field_options longtext, | |||
form_id int(11) DEFAULT NULL, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY form_id (form_id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_frm_forms' | |||
-- | |||
CREATE TABLE wp_frm_forms ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
form_key varchar(255) DEFAULT NULL, | |||
`name` varchar(255) DEFAULT NULL, | |||
description text, | |||
logged_in tinyint(1) DEFAULT NULL, | |||
editable tinyint(1) DEFAULT NULL, | |||
is_template tinyint(1) DEFAULT '0', | |||
default_template tinyint(1) DEFAULT '0', | |||
`status` varchar(255) DEFAULT NULL, | |||
prli_link_id int(11) DEFAULT NULL, | |||
`options` longtext, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_frm_items' | |||
-- | |||
CREATE TABLE wp_frm_items ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
item_key varchar(255) DEFAULT NULL, | |||
`name` varchar(255) DEFAULT NULL, | |||
description text, | |||
form_id int(11) DEFAULT NULL, | |||
parent_item_id int(11) DEFAULT NULL, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY form_id (form_id), | |||
KEY parent_item_id (parent_item_id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Table structure for table 'wp_frm_item_metas' | |||
-- | |||
CREATE TABLE wp_frm_item_metas ( | |||
id int(11) NOT NULL AUTO_INCREMENT, | |||
meta_key varchar(255) DEFAULT NULL, | |||
meta_value longtext, | |||
field_id int(11) NOT NULL, | |||
item_id int(11) NOT NULL, | |||
created_at datetime NOT NULL, | |||
PRIMARY KEY (id), | |||
KEY field_id (field_id), | |||
KEY item_id (item_id) | |||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; | |||
</source> | |||
[[Category: Portalware]] | [[Category: Portalware]] | ||
[[Category: Installation tips]] | [[Category: Installation tips]] |
Latest revision as of 15:32, 30 October 2020
Introduction
Wordpress (WP) is quote “a state-of-the-art publishing platform with a focus on aesthetics, web standards, and usability. WordPress is both free and priceless at the same time. More simply, WordPress is what you use when you want to work with your blogging software, not fight it.” (retrieved on Jan 19 2010).
This is a very outdated short installation and configuration manual which may be update in some far future. Please, read the fine official Installing Wordpress. The only reason I created this article, was to to have a short piece I could use with a projector in a web applications class and give out as handout. Personally I don't use Wordpress, but I think that it is one of the best systems to get started with the world of CMSs - Daniel K. Schneider 16:31, 19 January 2010 (UTC)/ 15:43, 13 September 2016 (CEST)~
Installation
(as of Jan 2010, should be ok in spirit in Jan 2011)
Installation includes four fairly easy steps:
- Create a MySQL database (or find information regarding the database you may use)
- Download the software package and unpack it to a web server directory
- Modify a PHP configuration file
- Launch the web installer (and answer 2 questions)
Creating a database
WP needs a MySQL database. The installation procedure will create many tables that normally should sit in their own database. You may find yourself in different web hosting situations.
(1) If you have a cheap or free provider or if you have a student account, you only may have access to a single database of the database system. This means that WP will have to co-exist with other applications in the same database. That is usually not a big problem, since most applications add a prefix to each table. By default, WP will add a 'wp_' prefix to each table.
(2) If you want to install WP with a "normal" shared webhosting provider, then you likely may use several databases. Consult the admin interface. Usually there is a tool that allows you to manage databases, e.g. add users and tune permission.
(3) If you have your own MySQL server, then you should install WP in its own database that you'll have to create, i.e.
- Create a database user (that WP will then use to connect to the database)
- Create a database that database user can access and fill up with table (and later, data)
In both cases you must create and/or remember:
- The name of the database
- The name of the database user
- The password of the database user
In this tutorial, we shall now cover one variant of situation (3):
- Creating a database and database user with phpMyAdmin
PhpMyAdmin is a popular database management system that is installed with most providers and that you also should install on servers you own. With this web-based administration, you can create a new database and user in different orders. The most easiest way is to use the following procedure:
(1) Click on the Privileges tab on the top horizontal menu
(2) Click on Add User at the bottom
- Then choose a user name, e.g. 'blog'
- Then select host=local or type localhost
- Enter the password twice (and remember it)
- Important: Tick Create database with same name and grant all privileges (this will create a new database)
- Crucial: Never grant any global privileges on a production server. Each database should have its own life (and hacking attacks).
If you do it right, you'll have
- database name = blog
- database user name = blog
- password = thePasswordYouEnteredTwice
Remark: Do not confound the mysql user and password with the wordpress administrator user and password that you will have to create later. The mysql user will be used by the PHP scripts of the WP software.
Wordpress installation
- Download and put code in place
- Download the WordPress package from http://wordpress.org/download/
- Unzip the package to your hard drive. You will see a directory called wordpress
- If you would your site's URL to be something other than http://xxx/wordpress, rename the wordpress directory. For example, if you wish to have a URL on your server like http://xxxx/blog, then rename the wordpress directory to blog.
- Transfer this directory to the web server tree, e.g. via FTP to a provider, to a local "www" directory or somewhere on your local area network. If you happen to use a WAMP system, the directory might typicall be something like c:\....\www, e.g. c:\servers\mowes\www or c:\wamp\www
- Run the installer script
(1) Access wp-admin/install.php from your web browser. E.g. on your local test server the URL might be something like:
http://localhost/blog/
You actually will be redirected to the following page:
http://localhost/blog/wp-admin/install.php
If you placed the WordPress files in a subdirectory called blog, for example, you should visit: http://example.com/blog/wp-admin/install.php
If WordPress can’t find the wp-config.php file, it will tell you and offer to try to create and edit the file itself. WordPress will ask you the database details and write them to a new wp-config.php file. If this works, you can go ahead with the installation; otherwise, go back and create, edit, and upload the wp-config.php file yourself (see below).
Remark: If you can't see the page or get an error message, please fix the syntax mistakes you just made before in the configuration file. If you cannot find the mistake by yourself, look at the server log. E.g. open file c:\...\apache2\logs\error.log. Else, ask a local expert to help.
(2) The script will then ask you to provide a name for the blog and an email address (the email address can bogus for a test system)
- Make absolutely sure to copy/paste the generated password to a safe place !!
(3) Log in
- Change immediately the password to a complicated one that you can remember well.
.... enjoy :)
- Edit the configuration file
(1) Rename the wp-config-sample.php file to wp-config.php. Make sure to get this right !
(2) Edit this file (wp-config.php) in a text editor. Do not use Word or Notepad ! Change information below, i.e. adapt to the database and database user names that you just defined above.
Base information:
/** MySQL database username */
define('DB_USER', 'blog');
/** MySQL database password */
define('DB_PASSWORD', 'blog');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
Change some security related parameters (you may skip this step if you test drive WP on a local server on your PC). In order to make cracking more difficult your wordpress will add extra characters to user's cookies, making it harder to crack encrypted passwords. You only need to do this once and you don't need to type these passwords ever. So use the online generator to generate this salt. Good examples would be:
define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg');
define('SECURE_AUTH_KEY', 'TufWOuA _.t>#+hA?^|3RfGTm>@*+S=8\"\4+\"}]<m#+}V)p:Qi?jXLq,<h\\`39m_(');
define('LOGGED_IN_KEY', 'S~AACm4h1;T^\"qW3_8Zv!Ji=y|)~5i63JI |Al[(<YS<2V^$T])=8Xh2a:b:}U_E');
define('NONCE_KEY', 'k1+EOc-&w?hG8j84>6L9v\"6C89NH?ui{*3\\(t09mumL/fFP_!K$JCEkLuy ={x{0');
Watch out:
- Both arguments of the define must be enclosed in quotes ' .... ' and each one must finish with semi-colon. Also, do not use unquoted quotes inside the security keys, else php will be confused. If you don't understand what this means, just use the generator and copy/paste.
define ('constant', 'value');
- For programmers who don't know PHP: define is an instruction that just defines a named constant at runtime.
- If you only own a single database and already have a wordpress installed, you also need to change the prefix towards the end of the configuration file. Else two different WP installations will use the same tables (very messy!)
$table_prefix = 'wp_';
So double check what you did and then save the file.
Configuration
Read:
- First Steps With WordPress followed by Administration Panels
- New To WordPress - Where to Start
- look up a chapter in the Working with WordPress manual, part of the Getting Started with WordPress
If you log in as admin, you will automatically see the dashboard, i.e. what is often called the backend.
From the official Administration Panel article, retrieved 17:55, 19 January 2010 (UTC), we reproduce: “Each Panel, referred to as SubPanel, that is accessed via the main navigation menu, is presented in the boxes below. The links in those boxes will lead you to sections of this article describing those SubPanels. From those sections, you can navigate to articles detailing more information about each SubPanel” Links will lead to the codex.wordpress web site therefore middle-click or right-click->Open in New Tab or Window if you like ....).
Maybe start with the following:
- Add an article (Add New)
- Change the theme
- Remove some links and add other ones
- Create two users, each beloging to a different category.
- Install plugins. This is really easy with Wordpress (just try)
Updating Wordpress
For security reasons, it is crucial to keep your WordPress site up to date. To update your site, select the Updates menu item from the sidebar and follow the instructions on the update page.
If your server requires an SSH or SFTP connection, you might get an error message during the update process. To connect to your server, you'll first need to install a plugin such as SSH SFTP Updater Support to enable those types of connection.
Plugins
Finding plugins
Plugins can extend WordPress to do almost anything you can imagine. In the official Wordpress plugin directory you can find, download, rate, and comment on all the best plugins the WordPress community has to offer.
Installing plugins
To install a plugin dezip into the wordpress /wp-content/plugins directory. Plugin should be in a subdirectory. Alternatively, you may directly search and install plugins from the Wordpress admin interface (recommended for beginners). Click on Plugins and then "Add New".
To activate a plugin, open the administration interface and click on the Plugins tab to open Manage plugins tool. You will see a list of plugins. Click and "Activate".
Configuring a plugin
Each plugin comes with a different set of tools. Some also include help, otherwise you will have to find help on the plugin web site.
The Insert Header and Footers plugin allows easily some types of custom HTML code. Quote (10/2020) "Insert Headers and Footers is a simple plugin that lets you insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site header and footer. No need to edit your theme files!". This plugin, as of oct. 2020 has over 1 Mio installs and therefore should be safe to use.
Once installed you can add code in Settings -> Insert Headers and Footers
Adding google fonts
How to Add Custom Fonts in WordPress from Wpbeginner (March 12th, 2020 when consulted on oct 2020) describes several methods. We chose the one that uses this plugin:
1) Go to google fonts
2) Pick a font. If you know the name, use search e.g. Barlow. The nclick on a result. You should see a list of styles
3) Pick a style variant in the list. E.g. for Barlow I took "regular" which also will include thin, bold and very bold.
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;700;900&display=swap" rel="stylesheet">
4) In WordPress, open Settings -> Insert Headers and Footers
Copy/paste the link from the Google page (i.e. the code above) into the "Scripts in Header" section.
5) Use the fonts
Open the theme: Appearance -> Themes
Select the active theme and click on Customize.
Open Additional CSS, and add CSS rules, e.g.
.h1 {font-family: 'Barlow', Arial, sans-serif; }
We suggest adding fallback fonts, in case the plugin stops working or something else goes wrong.
Forms builders
Below are plugins for creation of embedded "mini-databases". None of the free ones we examined is easy to use. Form building is fairly easy, but the main difficulty is to display the data. - Daniel K. Schneider 18:31, 21 February 2010 (UTC).
Formidable
Formidable allows to quickly and easily build forms with a simple drag-and-drop interface. However, if you want a tool for easy display of results, you will have to buy the commercial version.
TDO Mini Forms
TDO Mini Forms. “This plugin allows you to add highly customisable forms that work with your Wordpress Theme to your website that allows non-registered users and/or subscribers (also configurable) to submit and edit posts and pages”, retrieved 19:48, 18 February 2010 (UTC).
- Creation of the Indilean.com user contribution form with TDO Mini Forms is explained in this article and video
WordPress Form Creator
WordPress Form Creator “provides blog website owners with a truly easy to manage easy to configure forms solution for WordPress or WordPress CMS sites. In this release you can drag and drop the form elements to the generator page to create your forms.”, retrieved 19:48, 18 February 2010 (UTC).
Supple Forms
Supple Forms “makes it easy to create a custom meta box or write panel to enter data while adding or editing posts and pages. Supple Forms allows you to easily format and insert your data into posts by using shortcodes and HTML snippets.”, retrieved 19:48, 18 February 2010 (UTC).
Gravity Forms
Gravity forms (fully commercial)
Cforms
cforms is “a powerful and feature rich form plugin for Wordpress”. Display of collected data has to be progreammed manually. Free/GPL.
- Cforms seems to have a path problem when migrating. See the Advanced Edit Cforms
Using the CformsII plugin to collect and display data
Remarks:
- The Plugin control panel in WP includes a help file. Read it !
- Disclaimer: I never use Wordpress (and don't know anything about it), but I sometimes use Wordpress to teach about CMS/CMFs. If you know an easier solution to create data collection forms, please add it here - Daniel K. Schneider 20:50, 21 February 2010 (UTC).
(0) Installation
- Download the cformsII extension from deliciousdays.com
- Dezip in directory wordpress/wp-content/plugins/
You now should have a cforms directory inside the plugins directory.
- Click Plugins in the WP Dashboard and activate the plugin (as explained above).
(1) Creating a form
Creating a form with CformsII is fairly easy and we will not explain much here:
- Click on cformsII in the WP Dashboard
- Add new form (in the Admin Actions menu you find on top right)
- Click on update settings each time you make a change.
- Modify or remove existing input fields. Do not remove the Fieldset field, but you may rename it.
- **Add** as many new fields you like. Select the right position or move the field later.
If you want to learn form creation for real, read the help (available in the cformsII controls of the wordpress dashboard ....)
(2) Using the form
We suggest to retrieve user data with a page. Create a new page. In the editor, you now may insert cforms by clicking on the newly installed cforms button in the edit bar (Visual edit mode). Else, if you prefer manual HTML editing, insert:
<!--cforms name="COAP"-->
(3) To collect data to a database:
- Click on global settings in the cformsII control
- Click on "Database Input Tracking"
- Tick "Enable Input Tracking".
Don't forget to click on "Update Settings" ! You may check MySQL whether there are two new tables: wp_cformsdata and wp_cformssubmissions.
(4) Displaying results
To display results, you need to program. This seems to be a general "feature" of free Wordpress extensions....
A first solution is to create a new page template and modify it to deal with cformsII data. In wordpress, “Individual pages can be set to use a specific custom Page Template (a PHP template file, e.g., snarfer.php) you create within your Theme (see Creating your own Page Templates below on how to create a custom template). This new Page Template will then override the default page.php Page Template included with your Theme.” (retrieved 19:02, 21 February 2010 (UTC)).
All you need to do is to add some php code to display the table into the code. Then create a new page and use this new template. In the Edit Page interface, under Attributes (right column) you can change the the Template as shown in the picture to the right.
Below is a simple solution for displaying database contents for a given Cform. The CformsII API defines the following function:
get_cforms_entries( $fname, $from, $to, $sort, $limit ,$sortdir )
See the help for an explanation. All parameters are optional and we will just use the first one, i.e. $fname, to provide the form name.
Now, copy file wp-content/themes/default/page.php to wp-content/themes/default/cforms-page.php and modify it like this:
<?php
/*
Template Name: cforms-template
*/
?>
<?php
/**
* @package WordPress
* @subpackage Default_Theme
*/
get_header(); ?>
<div id="content" class="narrowcolumn" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php
// --------------------------------- Start cforms-modif
// all data from COAP form
$c_array = get_cforms_entries('COAP');
/* Uncomment the next three lines to debug or see what kind of data you get
echo "DEBUG c_array:<pre>";
print_r ($c_array);
echo "</pre>"; */
$cform_output = '<table border="1">';
$cform_output .= "<tr>";
$cform_output .= '<th>Problem</th><th>Name</th><th>Email</th><th>Website</th><th>Message</th>';
$cform_output .= "</tr>";
foreach( $c_array as $e ){
$cform_output .= "<tr>";
$cform_output .= '<td>' . $e['data']['Problem'] . '</td>';
$cform_output .= '<td>' . $e['data']['Your Name'] . '</td>';
$cform_output .= '<td>' . $e['data']['Email'] . '</td>';
$cform_url = $e['data']['Website'];
$cform_output .= '<td>' . '<a href="' .$cform_url. '">'. $cform_url . '</a></td>';
$cform_output .= '<td>' . $e['data']['Message'] . '</td>';
$cform_output .= "</tr>";
}
$cform_output .= "</table>";
echo $cform_output;
// --------------------------------- End cforms-modif
?>
<?php the_content('<p class="serif">Read the rest of this page »</p>');
?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
<?php comments_template(); ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Alternatively you also could install the Exec-PHP plugin from or a similar tool and activate it. Then just include the loop from the above code. However, this kind of feature is quite a security risk.
Database structure
Since we use Wordpress to teach about web databases (see e.g. the SQL and MySQL tutorial]], we include two database entity relationship diagrams (WP 2.7) and a dump of a relatively fresh Wordpress 2.9.1 installation below.
“The diagram below provides a visual overview of the Wordpress database and the relations between the tables (WP Version 2.5+) created during the WordPress standard installation. The Table Overview below includes additional details on the tables and columns.” (Database Description, Wordpress Codex, retrieved 20:46, 26 January 2010 (UTC).
Jaymin Kapish in his blog published alternative database diagrams for several wordpress versions, of which we reproduce the 2.7 version here and that you also may enlarge.
As you can see, Jaymin regroups various tables according to what kind of thing they describe. E.g. Roughly speaking, there are 4 tables to talk about Posts. He also uses a different notation for links. A 1-N relationship is shown as "X to Y" in the label. Arrows go from table to table (and not from field to field).
The following dump was made from an mostly unused WP demo installation of WP 2.8, automatically upgraded to 2.9.1. In addition, the dump includes four tables that belong to an extension called "formidable".
-- phpMyAdmin SQL Dump
-- version 3.1.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 26, 2010 at 09:39 PM
-- Server version: 5.1.35
-- PHP Version: 5.3.0
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: 'wordpress'
--
-- --------------------------------------------------------
--
-- Table structure for table 'wp_commentmeta'
--
CREATE TABLE wp_commentmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
comment_id bigint(20) unsigned NOT NULL DEFAULT '0',
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY comment_id (comment_id),
KEY meta_key (meta_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_comments'
--
CREATE TABLE wp_comments (
comment_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
comment_post_ID bigint(20) unsigned NOT NULL DEFAULT '0',
comment_author tinytext NOT NULL,
comment_author_email varchar(100) NOT NULL DEFAULT '',
comment_author_url varchar(200) NOT NULL DEFAULT '',
comment_author_IP varchar(100) NOT NULL DEFAULT '',
comment_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
comment_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
comment_content text NOT NULL,
comment_karma int(11) NOT NULL DEFAULT '0',
comment_approved varchar(20) NOT NULL DEFAULT '1',
comment_agent varchar(255) NOT NULL DEFAULT '',
comment_type varchar(20) NOT NULL DEFAULT '',
comment_parent bigint(20) unsigned NOT NULL DEFAULT '0',
user_id bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (comment_ID),
KEY comment_approved (comment_approved),
KEY comment_post_ID (comment_post_ID),
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
KEY comment_date_gmt (comment_date_gmt)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_links'
--
CREATE TABLE wp_links (
link_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
link_url varchar(255) NOT NULL DEFAULT '',
link_name varchar(255) NOT NULL DEFAULT '',
link_image varchar(255) NOT NULL DEFAULT '',
link_target varchar(25) NOT NULL DEFAULT '',
link_description varchar(255) NOT NULL DEFAULT '',
link_visible varchar(20) NOT NULL DEFAULT 'Y',
link_owner bigint(20) unsigned NOT NULL DEFAULT '1',
link_rating int(11) NOT NULL DEFAULT '0',
link_updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
link_rel varchar(255) NOT NULL DEFAULT '',
link_notes mediumtext NOT NULL,
link_rss varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (link_id),
KEY link_visible (link_visible)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_mngl_board_comments'
--
CREATE TABLE wp_mngl_board_comments (
id int(11) NOT NULL AUTO_INCREMENT,
author_id int(11) NOT NULL,
message text,
board_post_id int(11) NOT NULL,
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY author_id (author_id),
KEY board_post_id (board_post_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_mngl_board_posts'
--
CREATE TABLE wp_mngl_board_posts (
id int(11) NOT NULL AUTO_INCREMENT,
owner_id int(11) NOT NULL,
author_id int(11) NOT NULL,
message text,
`type` varchar(255) DEFAULT 'post',
`source` varchar(255) DEFAULT NULL,
visibility varchar(255) DEFAULT 'public',
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY owner_id (owner_id),
KEY author_id (author_id),
KEY `type` (`type`),
KEY `source` (`source`),
KEY visibility (visibility)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_mngl_friends'
--
CREATE TABLE wp_mngl_friends (
id int(11) NOT NULL AUTO_INCREMENT,
user_id int(11) NOT NULL,
friend_id int(11) NOT NULL,
`status` varchar(255) DEFAULT NULL,
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY user_id (user_id),
KEY friend_id (friend_id),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_mngl_friend_requests'
--
CREATE TABLE wp_mngl_friend_requests (
id int(11) NOT NULL AUTO_INCREMENT,
user_id int(11) NOT NULL,
friend_id int(11) NOT NULL,
friend_record_a_id int(11) NOT NULL,
friend_record_b_id int(11) NOT NULL,
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY user_id (user_id),
KEY friend_id (friend_id),
KEY friend_record_a_id (friend_record_a_id),
KEY friend_record_b_id (friend_record_b_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_options'
--
CREATE TABLE wp_options (
option_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
blog_id int(11) NOT NULL DEFAULT '0',
option_name varchar(64) NOT NULL DEFAULT '',
option_value longtext NOT NULL,
autoload varchar(20) NOT NULL DEFAULT 'yes',
PRIMARY KEY (option_id),
UNIQUE KEY option_name (option_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=220 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_postmeta'
--
CREATE TABLE wp_postmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL DEFAULT '0',
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_posts'
--
CREATE TABLE wp_posts (
ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_author bigint(20) unsigned NOT NULL DEFAULT '0',
post_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
post_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
post_content longtext NOT NULL,
post_title text NOT NULL,
post_excerpt text NOT NULL,
post_status varchar(20) NOT NULL DEFAULT 'publish',
comment_status varchar(20) NOT NULL DEFAULT 'open',
ping_status varchar(20) NOT NULL DEFAULT 'open',
post_password varchar(20) NOT NULL DEFAULT '',
post_name varchar(200) NOT NULL DEFAULT '',
to_ping text NOT NULL,
pinged text NOT NULL,
post_modified datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
post_modified_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
post_content_filtered text NOT NULL,
post_parent bigint(20) unsigned NOT NULL DEFAULT '0',
guid varchar(255) NOT NULL DEFAULT '',
menu_order int(11) NOT NULL DEFAULT '0',
post_type varchar(20) NOT NULL DEFAULT 'post',
post_mime_type varchar(100) NOT NULL DEFAULT '',
comment_count bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (ID),
KEY post_name (post_name),
KEY type_status_date (post_type,post_status,post_date,ID),
KEY post_parent (post_parent)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_terms'
--
CREATE TABLE wp_terms (
term_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL DEFAULT '',
slug varchar(200) NOT NULL DEFAULT '',
term_group bigint(10) NOT NULL DEFAULT '0',
PRIMARY KEY (term_id),
UNIQUE KEY slug (slug),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_term_relationships'
--
CREATE TABLE wp_term_relationships (
object_id bigint(20) unsigned NOT NULL DEFAULT '0',
term_taxonomy_id bigint(20) unsigned NOT NULL DEFAULT '0',
term_order int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (object_id,term_taxonomy_id),
KEY term_taxonomy_id (term_taxonomy_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_term_taxonomy'
--
CREATE TABLE wp_term_taxonomy (
term_taxonomy_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
term_id bigint(20) unsigned NOT NULL DEFAULT '0',
taxonomy varchar(32) NOT NULL DEFAULT '',
description longtext NOT NULL,
parent bigint(20) unsigned NOT NULL DEFAULT '0',
count bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (term_taxonomy_id),
UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
KEY taxonomy (taxonomy)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_usermeta'
--
CREATE TABLE wp_usermeta (
umeta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id bigint(20) unsigned NOT NULL DEFAULT '0',
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
PRIMARY KEY (umeta_id),
KEY user_id (user_id),
KEY meta_key (meta_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_users'
--
CREATE TABLE wp_users (
ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_login varchar(60) NOT NULL DEFAULT '',
user_pass varchar(64) NOT NULL DEFAULT '',
user_nicename varchar(50) NOT NULL DEFAULT '',
user_email varchar(100) NOT NULL DEFAULT '',
user_url varchar(100) NOT NULL DEFAULT '',
user_registered datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
user_activation_key varchar(60) NOT NULL DEFAULT '',
user_status int(11) NOT NULL DEFAULT '0',
display_name varchar(250) NOT NULL DEFAULT '',
PRIMARY KEY (ID),
KEY user_login_key (user_login),
KEY user_nicename (user_nicename)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
Structure of formidable, a form management tools plugin
--
-- Table structure for table 'wp_frm_fields'
--
CREATE TABLE wp_frm_fields (
id int(11) NOT NULL AUTO_INCREMENT,
field_key varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
description text,
`type` text,
default_value longtext,
`options` longtext,
field_order int(11) DEFAULT '0',
required int(1) DEFAULT NULL,
field_options longtext,
form_id int(11) DEFAULT NULL,
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY form_id (form_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_frm_forms'
--
CREATE TABLE wp_frm_forms (
id int(11) NOT NULL AUTO_INCREMENT,
form_key varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
description text,
logged_in tinyint(1) DEFAULT NULL,
editable tinyint(1) DEFAULT NULL,
is_template tinyint(1) DEFAULT '0',
default_template tinyint(1) DEFAULT '0',
`status` varchar(255) DEFAULT NULL,
prli_link_id int(11) DEFAULT NULL,
`options` longtext,
created_at datetime NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_frm_items'
--
CREATE TABLE wp_frm_items (
id int(11) NOT NULL AUTO_INCREMENT,
item_key varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
description text,
form_id int(11) DEFAULT NULL,
parent_item_id int(11) DEFAULT NULL,
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY form_id (form_id),
KEY parent_item_id (parent_item_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table 'wp_frm_item_metas'
--
CREATE TABLE wp_frm_item_metas (
id int(11) NOT NULL AUTO_INCREMENT,
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
field_id int(11) NOT NULL,
item_id int(11) NOT NULL,
created_at datetime NOT NULL,
PRIMARY KEY (id),
KEY field_id (field_id),
KEY item_id (item_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;