Power Up Your Website: Integrate Nuxeo with WordPress
Chances are you are already quite familiar with WordPress. It is a widely used free and open-source content management system (CMS) and the world’s most popular blogging system. WordPress powers over 60 million websites, including Nuxeo. As impressive as WordPress already is, you can really put the power of your WordPress site into high gear by integrating the Nuxeo Platform with WordPress.
Why integrate the Nuxeo Platform with WordPress
WordPress has its own content management feature (Media Library) that integrates links with documents inside published web pages. However, the Media Library is quite simple and basic - you can only upload documents, add some information and manage status.
The Nuxeo Platform offers much more interesting features and the ability to store a huge amount of data. So it's a good idea to use it as a back office for WordPress.
Use Case: Integrate dynamic links in WordPress pages to documents in the Nuxeo Platform
A few weeks ago, we developed a plugin for a customer to integrate links in WordPress pages to documents stored in the Nuxeo Platform (with additional information). The associated architecture is as follows:
This module has been developed as a plugin (a zip file) that can be easily deployed through the Plugins menu of WordPress. This plugin has three parts:
- Administration part : Used to manage the configuration menu of the plugin inside WordPress.
- Main part : Used to manage the requests coming from the WordPress pages.
- Automation part : Used to allow the main part to communicate with the Nuxeo Platform through Automation API (REST). This automation part is a PHP automation client that was previously available in our GitHub repository.
On the Nuxeo side we used an SSO plugin to allow accessing documents in the Nuxeo Platform without having to sign in each time (under the account of the currently connected user). We used the nuxeo-platform-login-mod_sso plugin that allows authentication based on a header token between WordPress and the Nuxeo Platform.
This plugin works on the principle of shortcode. This means that you will just have to write a specific Nuxeo shortcode on your page (in Edit mode). This code will be dynamically evaluated at run time and transformed into a list of documents. For example, consider the following code:
If you put this code on your page, a NXQL query will be generated at runtime and the result will be displayed as a table of documents with their metadata:
A click on the name of a document will download the file stored in the Nuxeo Platform. It's not a direct link to the platform but a link that is managed directly by the plugin to allow the use of the SSO (The Nuxeo Platform isn't visible to the end users).
The grammar of the shortcode is summarized here:
- [nuxeo path="/my particular/folder name/"]: Displays the content of a folderish document based on its path (under the configured domain path)
- [nuxeo type="File"]: Displays Documents matching a specified type
- [nuxeo nxquery="SELECT * FROM File WHERE ..."]: Displays Documents based on the NXQL query terms provided
- [nuxeo name="Agenda%.doc"]: Documents whose name matches (May include wildcard character '%')
- [nuxeo doc_id="c5e890d3-87f5-42cb-abe4-1ed9d0d2600c"]: Displays the details of a document based on its id
- [nuxeo folderish_id="05cdeaa1-e57d-450a-8347-1600206e7cce"]: Displays the content of a folderish document based on its id
Some of these parameters can be mixed together, for example:
- [nuxeo path="workspaces/Docs/Samples" name="Doc" type="File"]: Displays the documents of type File whose name starts with 'Doc' and that are located under the Samples Folder
The global parameters of this plugin are available in the WordPress Settings menu.
The goal of most of these parameters is quite obvious. Notice that the fields, Username and Password, are now deprecated because we are dynamically using the account of the user who is currently connected (through the SSO).
The Display NXQL Query can be used to display the complete NXQL Query generated before the rendering of each shortcode, as shown below:
The source code of this plugin is available here: https://github.com/nuxeo/nuxeo-wordpress-plugin.
In future, we will implement more features:
- Improvement of the rendering (For example, metadata selections)
- Icons based on the document mime type
- Integration with the Media Library
So, try out this plugin and tell us about your experience!
Category: Product & Development