Daiquiri and Wordpress

Daiquiri can be combined with WordPress to add a powerful content managing system or blogging system, respectively. Daiquiri provides a special theme and a plugin for WordPress to seaming less integrate the two systems. In particular, WordPress will use the layout given by daiquiri and users will not need to log separately.

Obtain Wordpress

The first step is to obtain the latest version from wordpress.org. For this documentation we assume that the wordpress files sit in /srv/wordpress which is the default in the Daiquiri configuration. Once obtained, extract the tar achive.

cd /srv/wordpress
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
chown -R www-data:www-data wordpress # debian/Ubuntu
chown -R apache:apache wordpress     # RHEL/Centos/SL

Configuration

WordPress needs a config file which is enabled by copying the default file:

cp wordpress/wp-config-sample.php wordpress/wp-config.php

In the config file, a database user needs to be set (DB_NAME,DB_USER,DB_PASSWORD, the WordPress database need to be on the same server as the Daiquiri web database), the different unique phrases have to be set with random strings, and the following lines need to be added before the That's all, stop editing! Happy blogging. comment:

define('DAIQUIRI_URL','http://www.example.com/'); // put the daiquiri url here
define('DAIQUIRI_NAVIGATION_PATH','/srv/navigation');
define('COOKIEPATH','/');
define('SITECOOKIEPATH',COOKIEPATH);      // do not edit
define('ADMIN_COOKIE_PATH',COOKIEPATH);   // do not edit
define('PLUGINS_COOKIE_PATH',COOKIEPATH); // do not edit

In case you chose to run Daiquiri under an alias, you need to set COOKIEPATH to this alias. When the two database users for Daiquiri are created, create a third one with the credentials in wp-config.php, and a corresponding database.

Enable WordPress integration in Daiquiri

Next WordPress needs to be enabled in Daiquiri. If you have not setup the application yet, just add

'cms' => array(
    'enabled' => true,
)

to the config part of the $options array. Optionally, you can specify a few more variables:

'cms' => array(
    'enabled' => true,
    'url' => '/cms/' // the url under which the WordPress resides
    'path' => '/srv/wordpress' // path of WordPress
    'navPath' => '/srv/navigation' // path of the navigation partials
)

The configuration entries are also described here.

If the application is already set up, please add the config entries cms.enabled,cms.path, and cms.navPath manually using the admin configuration entry page. Please also include the entries in the init.php file as shown above, since this is needed for the links in the next step.

Setup Wordpress

Then link the WordPress directory into the public folder of your daiquiri application using:

./init.php -l

Next, link the Daiquiri theme and the plugin manually into the WordPress directory. By linking (not copying) we ensure that it can be as easily updated as the rest of Daiquiri. For the default path this would write:

ln -s /srv/daiquiri/library/Wordpress/theme /srv/wordpress/wp-content/themes/daiquiri
ln -s /srv/daiquiri/library/Wordpress/plugin /srv/wordpress/wp-content/plugins/daiquiri

Finally open the specified WordPress url (default: /cms/) in your browser and perform the WordPress setup. For this create a new database user with password, which does not need to be related to the daiquiri user in any way. For the admin credentials choose an email address which will never be used by an actual daiquiri user (e.g. admin@example.com). The admin account will only be used for the initial setup and perhaps in a case of emergency.

After the installation of WordPress is done, log in as the admin user you specified and enable the theme in the WordPress back-end under Appearances. Then go to Plugins and enable the Daiquiri plugin.

Optionally, but recommended: enable nicer permalinks by selecting Post name under Settings->Permalinks. Also under Settings->Reading you can setup a static front page instead the dynamic blog for the root url of WordPress.

Then Log out of WordPress using the menu in the top right corner. From now on whenever a user is logged in in Daiquiri he is also logged in in WordPress. Daiquiri admins are also admins in WordPress, managers are editors (they can edit pages), and users are subscribers (they are just recognized by wordpres regarding comments and such).

Use dynamical WordPress menus in Daiquiri

Menus which are created inside WordPress (Appearance->Menus) can be used in the layout or any other view of your Daiquiri application. For this, use the wpNavigation helper inside your layout/view:

<?php echo $this->wpNavigation($menu); ?> // $menu is the menu name in WordPress

Whenever the menu is saved in WordPress, its html code is saved in the directory specified in daiquiri_navigation_path and the subsequently rendered in the daiquiri layout/view. For a bootstrap dropdown menu like the Documentation menu used on this page, the code reads:

<li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
        Documentation
    </a>
    <ul class="dropdown-menu">
        <?php echo $this->wpNavigation('documentation'); ?>
    </ul>
</li>

Protect certain pages (Intranet scenario)

In order to restrict certain pages to registered users, we recommend the User Access Manager plugin.

First, install the plugin via the Wordpress backend. Then create a user group which is affiliated with all roles. (Daiquiri admins are Wordpress admins, managers are editors, and users are subscribers).

From now on every page and post has a checkbox which can be used to restrict the page to the created group.