Sunday, 24 August 2014

How to display Trustpilot RSS feed in MODX

This article describes how to modify the getFeed extra for MODX to display reviews from a Trustpilot RSS feed on your website.

One of my clients uses the Trustpilot customer review service and wanted to display the reviews they have received on their website. In order to display the reviews in a format to match the client's branding it was decided to use the Trustpilot RSS feed and style it to suit.

Customised Trustpilot RSS Reader for MODX

The getFeed extra by Shaun McCormick (splittingred) would be perfect to read the Trustpilot feed but it contains fields with semi colons that getFeed cannot access.

See: 01 trustpilot-rss-example.xml

Luckily Jiri Pavlicek has already experienced this issue and provided a fix over on GitHub by making a small change to the original.

To ensure the changes are not overwritten if the original getFeed Snippet is updated via Package Manager I created a duplicate called it getFeedPlus.  There are no additional properties so it is called in exactly the same way as getFeed.

See: 02 getFeedPlus-call.txt and 03 snippet-getFeedPlus.php

Styling the output

A template Chunk is required to handle the output of the feed items.

See: 04 chunk-trustpilot.tpl

Tidying the pubDate

The Publication Date is a little untidy as it includes the timestamp and timezone eg.
Fri, 01 Aug 2014 08:14:36 GMT

An easy way to tidy this is to trim the end off the string by applying an Output Modifier to the pubdate placeholder in the template:
[[+pubdate:limit=`16`]]

This outputs the Publication Date in a more friendly format:
Fri, 01 Aug 2014

Displaying the Star rating

The review template chunk-trustpilot.tpl calls the trustpilot-stars snippet which calculates how many stars were awarded for by the current review and outputs a block of html (chunk-trustpilot-star.tpl) for each star awarded.

See: 05 snippet-trustpilot-stars.php and 06 chunk-trustpilot-star.tpl

The Result

The custom layout integrates perfectly into the client's website and doesn't require the extra Javascript call that is required by the TrustBox Widget provided by Trustpilot.

Example of custom output from Trustpilot RSS feed

Code


Tuesday, 23 July 2013

Delete Directory and Contents using DOS Command Prompt

Open Command Prompt and enter the following, replacing path between quotes with path to folder to delete.
RD /S /Q "C:\Users\UserName\Desktop\Folder"
Switches:
/S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S

Thursday, 25 April 2013

Enable Table Controls in FCKeditor on OpenCart

ckeditor config js location:
admin/view/javascript/ckeditor/config.js

Change 

['Image','Table','HorizontalRule']
 


To

['Image','Table','HorizontalRule','Format']

Sunday, 3 February 2013

How to duplicate a row in MySQL

INSERT INTO table_name (field_name1, field_name2, field_name3, field_name4) SELECT field_name1, field_name2, field_name3, field_name4 FROM table_name WHERE id = 87

INSERT INTO table_name (field_name) SELECT field_name FROM table_name WHERE id = 87

Thursday, 13 December 2012

MODX 2.2.2 on IIS 7.5 - Authentication Required (Manager login)

On a recent install of MODX 2.2.2 attempting to login to the Manager threw a Windows Authentication dialogue box.  Selecting Cancel allowed access to the login screen on internal browsers (FF, Chrome and Opera) but could not be bypassed at the client's location.

Disabling Windows Authentication in IIS for the client's website prevents the Authentication box from being shown.

Interestingly Firebug showed that all the required files associated with the login page were sent to the browser even though the Authentication dialogue appeared.



Thursday, 6 December 2012

MODX Dashboard shows 500 Internal Server Error on Login

An issue occured with the MODX News and Security feeds today causing IIS to throw a 500 Internal Server Error on login.  If IIS is set up to show detailed errors the actual error is displayed:
Reserved XML Name at line 1, column 38

This error will appear twice if both News and Security feeds are enabled and will disappear if the feeds are disabled.

Disable MODX News and Security Feeds

To prevent the error you need to access the System Settings:
  • System > System Settings
  • Filter by Area > System and Server
  • Set MODX Security Feed Enabled and MODX News Feed Enabled to No
Accessing System Settings when the navigation does not appear means you need to know the URL or have any other manager URL in your browser history that can load a page where the navigation will display.  The System Settings URL is likely to be:
http://www.domain.co.uk/manager-location/index.php?a=70

Related settings

The following settings are usueful to know when working with the News and Security feeds:

 Changing Feed Headings

  • System > Lexicon Management
  • Topic > Dashboard from the dropdown
  • Set new values for modx_news and security_notices

Changing Feed URLs

  • System > System Settings
  • Filter by Area > System and Server from the dropdown
  • MODX Security Notices Feed URL
Note: this relates to MODX Revolution v2.2.4, some item names or locations may be different on other versions.

Thursday, 19 April 2012

Add new columns to table in MySQL

The ALTER TABLE command can be used to add new columns to an existing table in a MySQL database:
ALTER TABLE table_name
ADD column_name datatype (eg. tinytext)
To add the column after an specific existing column add:
AFTER existing_column
To add multiple columns with the same statement a number of ADD commands can be chained together and separated with commas:
ALTER TABLE table_name
ADD social_url_twitter tinytext,
ADD social_url_facebook tinytext,
ADD social_url_blogger tinytext