Speeding up WordPress

My! This is slow.  More will follow!

Benchmarks

Using Google Page Insights,

Page Speed at Time 1

I have two speed benchmarks.

Mobile: 67

Desktop: 85

Page Speed benchmarks from a small WP site

My main page (that is not responsive) using a WP theme written by myself has comparative figures of 91 and 96.

Page Speed  benchmarks from a large Drupal Site (university)

Mobile: 52 & Desktop: 65

Page Speed benchmarks from another university site (CMS unknown)

Mobile: & Desktop: 72 & 74

Tests

Remove unneeded plugins and themes; changed themes

Marginal improvement

Mobile: 68

Desktop: 85

Found a theme with following speeds

Mobile: 79

Desktop: 86

Blog too big? Tidy up and make eBooks?

Blog too big to manage? Does WordPress have plugins to help?

I have almost a thousand posts on this blog and I would dearly love to tidy them up; but this is a horribly big job.  Posts for one year alone come to about 500 printed pages and there is almost a decade of writing on here.

My search for  eBook plugins  for Word press begins

MPL plugin for WordPress

I have just now downloaded and activate my first eBook plugin: MPL.

Over the coming days I will test it and then try others too.

What I hope to do to tidy my blog

Goal 1:  Dead posts

When I spot a post that I really do not want to keep, I would like to delete it.

The post might be important to other people though.  Before I delete it, I will check on the Google statistics on Google Analytics, the analytics through Jetpack, and if it is an old post, the statistics on the original wordpress.com blog that I had and that redirects here.

How do I know if someone links to it?  And does it matter, if the link delivers no traffic?  It would be good to find out though.

My statistics will include

  1. The number of posts considered for deleting
  2. The number retained anyway
  3. Why I retained them

Goal 2: Interesting posts that might maintain a sense of my interests changing over the years

A post may be pretty much dead but it might be a market of my interests over the year.  Nostalgic perhaps, but I would like to complete those.

Maybe, I should simply make one of my eBooks – The first decade.

Indeed, this is the value of writing. I will do this first to give myself an overview of the blog.

Can I download a list of all 1000 posts, with their dates, tags and comments and look for a pattern?

Can I find out their current traffic too?

Task 1:  Get overall statistics for my blog

?? What is missing here?

WordPress to Drupal : First steps

 

I plan to use Drupal to re-organize this large blog: flowingmotion.jojordan.org.  This post lists the beginning steps.  Each step is quite large and if you are completely new to web development, you will need to look up and complete each step as a mini-project.

  1. Make a development environment on my laptop.  Set up WAMP.
  2. Set up Drush so that I download Drupal and its modules more easily.
  3. Set up a clean database in WAMP / PHPMyAdmin.
  4. Download the latest version of Drupal 7 and unpack it into folder in c:/wamp/www/myblog
  5. Go to my browser and install Drupal: “localhost/myblog”
  6. Use the command line to use Drush : “cd c:/wamp/www/myblog”
  7. Use Drush to download and enable the modules for “pretty url”
    1. drush dl token pathauto
    2. drush en -y token pathauto
  8. Chose a theme and use Drush to download/upload it.  I used Stanford’s Open Framework and downloaded it manually to /myblog/sites/all/themes.
  9. Logged in, set the time to UK and set up the date format.
  10. Under Appearance, set the Open Framework to the default
  11. Use Drush to install the modules needed for WordPress_Migrate (see above for the commands): migrate ctools features  media media_youtube migrate_extras
  12.  As of today’s date though this will change, do not download WordPress_migrate with drush. Go to its webpage and install the latest development version
  13. Go to Add Content and select Migrate. Look for the Worpress link
  14. Follow the instructions – all of the them!
  15. I  tried to retained my WordPress urls but that did not work and the aliases are borked too.  As it was not straightforward finding this workflow, I will leave this for now and worry about sorting my comment.

These are the basic steps for importing WordPress content into Drupal. It is not perfect but as this is a one off import, it is satisfactory.

WordPress to Drupal

Here begins my migration from WordPress to Drupal.

Why move from WordPress to Drupal?

I don’t advise anyone to move from WordPress to Drupal unless they have a strong reason.  WordPress is friendly and you will be functional and confident in few months.

Drupal is overly complicated, bloated and very badly documented.

So why move to Drupal?

Drupal is designed for complicated sites.  The Views facility, that is, it’s query function is very powerful.

This blog, Flowingmotion.jojordan.org has grown very big.  I don’t even remember everything i have written.   And I would like to find out.  I would like to delete what is no longer of any use. I would like to organize what is still valuable. And I would like to rewrite what could benefit from rewriting.]

The benefits of migrating from WordPress to Drupal

I intend to download the content of this WordPress blog onto a development site on my laptop and reorganize its content.

I will use a Drupal module to do a rough-and-ready migration.   Then I will start allocating posts to “Books”.   That is, I will set up a “Book” and cross-reference them to existing posts.  Once I have done that, I will be able to make a plan for each Book or collection.

I have also chosen a simple base them to think ahead to a “responsive” theme. I want people to be able to read my “Books” on their mobiles. When I rewrite the posts, I will take the smaller screen estate into account and chunk and structure the posts so that people can follow a complicated idea more easily.

Uniform Server unexpectedly throws a php5ts.dll error

Uniform Server is a portable version of WAMP. Apologies if you are an expert developer but some people arriving here may not be so let me explain a little.

What is WAMP?

WAMP means Windows Apache MySQL PHP. It is a bundle of web server, database server and PHP language that we download onto our Windows laptops so that we can develop new websites locally.

What is Uniform Server?

What does portable mean in practice?

Uniform Server is a portable version of WAMP. You can install it on a USB stick and use it without installing it on your laptop. This is very useful when you are working in situations such as universities where you may not want to lug your laptop around with you. You can take your USB stick from office to library to lecture hall and plug it in to whatever computer is there. When you pull it out, you have left no “registry dust”, i.e., you haven’t changed the configuration of the computer at all. But you may have changed the content on the USB. The equivalent for Word would be that Word has been installed on the USB rather than on the computer.

What happens when I buy a new laptop before my project has ended?

A portable server is also useful when we have a long project because over the life of a long project, a laptop is likely to be replaced. By having everything to do with a project on a standalone portable server, we simply plug the USB into the new laptop. We don’t have to stop and think – what software is on here? What needs to be installed? Will the versions be compatible, etc.?

How do I make backups?

Having server, software and data in one place is also handy for backups. Though this makes for a big file, we usually handle backups in three levels. The server is backed-up. The program files are backed up. And the data files are backed up. Backing up at three levels is good practice and makes sense when the server is shared, when the program files are common and when data is specific. But for many researchers, a failure is a nightmare. We aren’t thinking in terms of three levels and panic ensues when something fails. Sorting the mess out can take days because we are unfamiliar with the processes. A bundle on a USB obviates that panic. Back up nightly. It is a bit slow but if the work is important, back up onto another USB or even onto your laptop and backup again via a tunnel to the university’s servers. Then the worst case scenario is a 24 hour loss. Just pick up yesterday’s USB and begin again there.

The flaw in Uniform Server

But I have discovered a flaw in the system. I had an old version of Uniform Server running on my laptop: 8.6.4. I started it up and it threw an error.

Diagnostics

1. C:\my_uniform_server_directory_name\my_website_folder\usr\local\php\php5ts.dll was present.
2. I had other versions of Uniform Server on my laptop. Shutting down the first and starting up others threw the same error.
3. There was sometime between last time I started up Uniform Server and the error. It seemed unlikely that multiple versions of php5ts.dll had been corrupted and much more likely that something downloaded to my computer since I last used Uniform Server was clashing.
4. And here is the flaw. Though Uniform Server is fully portable, the path name set up within Uniform Server does not explicitly reference php5ts.dll. This means that when this .dll is called, Windows looks at it generic path statement and accesses the php5ts.dll in other versions of PHP on your computer (or fails to find it).

The fix for the php5ts.dll error

1. For each and every version of Uniform Server on your computer or USB stick, edit C:\my_uniform_server_directory\my_website_folder\usr\local\apache2\conf\httpd.conf to include a direct reference to the php5ts.dll file that came with Uniform Server. Simply add the last line to the list of code shown below.

Loadfile “C:/portables/ouruni.com/usr/local/php/ssleay32.dll”
Loadfile “C:/portables/ouruni.com/usr/local/php/libeay32.dll”
Loadfile “C:/portables/ouruni.com/usr/local/mysql/bin/libmysql.dll”
Loadfile “C:/portables/ouruni.com/usr/local/php/libpq.dll”
Loadfile “C:/portables/ouruni.com/usr/local/php/php5ts.dll”

5. Save, stop Uniform Server if it is running and restart. All should be well.

In short, phpt5ts.dll and Uniform Server

1. If you have an error message about pht5ts.dll, then check the file is present.
2. Think if there is any reason that if could have been corrupted.
3. Check the httpd.conf file and add the direct reference.
4. Test.
In all likelihood, Uniform Server was not picking up its own version of pht5ts.dll.

 

Using data.frame in R

Data frames in R

A useful feature of R is the data.frame.

What is a data.frame?

Without being an expert in R: a data.frame is like a table.  So when I read a table from a .csv file, then it read it into a data.frame.

mydata<-read.csv(“myfile.csv”, header=TRUE).

Reshape data with a data.frame on the fly

A very useful feature of a data.frame is that I can construct it, on the fly, so to speak.

Let’s say I make a list that could correspond to column, in ordinary English.

matrix(col1,10,1)

And now imagine that I concatenate ten letters into a row:

row1= c(“a”,”b”,”c”,”d”,”e”,”f”,”g”,”h”,”I”,”j”)

I can make data.frame of two columns with col1, as is, and row1 turned into a column.

data.frame(col1, row1)

This is a very handy piece of data reshaping and I can do this with any combination of numbers.

I can also make this a bit neater add headings to my columns by extending the command

data.frame(vname1 = col1, vname2 = row1)

If I need to return this from a function then of course I place the command in the line above where the x is: return(x)

If I need to put the data.frame into an object, then myobjectname<-data.frame(vname1 = col1, vname2 = row1)

 

A simple ‘to do’ list for Drupal 7 using Date & Calendar

This post describes a very simple ‘to do’ list that I made in a Drupal 7 website.

The website already had a Calendar and Date function.  I can add a Date, and all its details, which is recorded as a node of content-type Date and displayed on a Calendar View.

Already installed and enabled : Drupal 7, Token, Pathauto, CTools, Views and Views UI, Date, Calendar, Computed Field

To add items and to put them on and off the ‘to do’ list

To make this simple to do list, I decided –

  1. To add the things I want ‘to do’as a Date and, if they have no date, I record an arbitrary start date – say the end of the quarter or the end of the half.
  2. When I want to move an item to my active ‘to do’ list, I simply edit the item and change the start date to today or if it on this week’s list, to Monday.
  3. When I have finished the task, I edit the item again to reflect the finish date.
  4. As I will describe below, an odd feature of the filter’s in Views required an extra Boolean filed so I check a box when the task is complete.

Permanent record

With this simple set up, I have a permanent record, in one place, of all my projects that are pending, and of all my projects in the past with the dates when I started them and finished them

Adding focus

To keep me thoroughly focused, I made two taxonomies – one for work and one for leisure. Both of these were added to Date so that later I can retrieve work and leisure activities into separate Views.

Additional information

As I have both start and end information, I added another field to Date to calculate the Elapsed Time between the date I started and ended a project. There is code available on the internet and I repeat it here.  Simply, we retrieve the entity values for the two times, make DateObjects with the values, and then choose our granuality (‘days’).

I also added another field to Date, Days in Queue, and added similar code to calculate the time between the day the Date was added and the start date.

To display my ‘to do’ list

To display my current ‘to do’ list, I made a View in a Block, in table format, and display the taxonomy tag and Date title

I also added two filters. First, using a Relative filter, I selected Dates with a start date equal or larger than now.  Second, I searched on the Complete check box.  It is important to manually put in 1 and 0 as the default values when you set up the field initially, otherwise they will filter will not work in the View. The reason that I added what seems to be a superfluous checkbox is that the default finish date for a new task is not NULL, as one might expect, but the start date. The only way to select tasks that have been started and not finished is to add the extra box.

As I have made a Block, I can put the Block in a side bar.

Note also that we can tell the Block View to order the items in the order of the Taxonomy.  So when you set up the Taxonomy, ensure you put the tags for work into the order of your daily routine.

Note also that I did try using Editable Views but firstly, it did not work out of preview, and secondly, the preview showed a massive date edit screen that would not be user friendly.  So to record a project as finished, I follow the link and edit the Date and check the complete box.

To set up my ‘to do’ list

To review my pending list of items in the queue, I made another View, this time as a page. This time I use all four fields – Date, title, Elapsed Time, Days in Queue – in a table.

I can also filter by taxonomy.

Here I can pick my items, follow their link and change the start date to today or Monday.

To review what I have achieved

For those days when I have been buried in a task and feel that I have achieved nothing, I have an ordinary View of all four fields – Date, title, Elapsed Time, Days in Queue – in a table. This time, I have two exposed filters.  The first is headed, ‘Finish on or after’ and the second is headed, ‘Finished before’.

By setting my time range, I can immediately see what I have finished during the period in question.

Leisure

I can repeat the entire setup for leisure items.

Features to be developed

My next tasks will be to track my Elapsed Time and Days in Queue, particularly for work items.

To understand my own planning behaviour better, I will group all my Dates by week and count the number of items inserted and the number of items that are finished. Now I will have the basic information to understand my queue – how fast am I adding things and how fast am I finishing things.  Ideally, I’ll plot these numbers on a graph.

To understand the chunking of my tasks, I’ll group them again by week and calculate the minimum, average and maximum Elapsed Time.   Hopefully, both the spread of times and the average time will decrease below 5 days – meaning, I have designed tasks that can be finished within a week.

And I will calculate the minimum, average and maximum Elapsed Time and Days in Queue for a moving period of quarters, halves and years so that I can be aware of how long I take to complete something I have decided to do and how my behaviour changes in time.

Summary

There it is.  A simply backlog manager.  Add Dates to a Calendar.  Use Computed Fields to monitor both the Elapsed Time and the Days in Queue. Use a check box to show a task is complete because filtering by a blank end date does not work.  And add two taxonomies so that you can split your lists and display tasks in order.

How to make a Slideshow in Drupal 7

How to make a slideshow in Drupal

The concept behind a slideshow

A slideshow in Drupal is actually a View.   A View is a query that will search through your pile of nodes, pick out any that match the criteria you set, and display them in a format you set.  Slideshow simply extends Views to layout your content in a slideshow with our without a carousel.

This post will describe how to get the slideshow working without a carousel.

Before you start

Before you start, you will obviously need a working Drupal website with some content, such as a collection of images.  You can also use a slideshow to display ordinary posts as I do on the front page of Rooi.  We will use images here because that is the more common use.

Additionally, you need to have View downloaded and enabled and you will also have to enable its sub-module View_UI.

You also need to know, at least roughly what the following mean:

  • Page and block
  • Content-type, node and field

Modules & Plugin

To set up Slideshow, you will need the modules: Libraries, Views _Slideshow, Views_Slideshow_JCarousel and Libraries.  When you enable Views Slideshow, also enable Views_Slideshow_Cycle.

Additionally, you will need the jCycle plugin which you download from https://github.com/malsup/cycle (get the .zip file on the right).

Unpack the file into your Libraries folder. If you don’t have a Libraries folder, make one under /sites/all/.  Rename the folder that the .zip file creates as jquery.cycle.

Make a View Slideshow

You will recall that to make a View, you go to Structure/Views and make a new view.

Screen 1

  1. Add a name and a description
  2. Choose your content.   Notice that everything on the list is a content-type. If you have a separate content-type for images, choose it. Otherwise choose a content-type that has a field for images. The default content-type Article has a default field for images and I chose Article.
  3. Decide whether you want to display your slideshow on a page or a block.
  4. If you chose page, check the path.
  5. At format, choose slideshow.
  6. Set the number of images to show before pagination kicks in.
  7. Decide whether you want a direct link to show on a menu.
  8. Continue & edit but beware, your work has not been saved at this point.

Screen 2

  1. The second screen has a baffling array of controls.  Look over them carefully and ignore Advanced Options in column three for the moment.
  2. The middle column controls the path, the links to menus, the permissions, and pagination.
  3. Most of the controls that you want for a slideshow are in column one.
  4. Starting at the top, you see Display Name and Title. Display name is the name used to when Views are listed. Title is the name displayed as part of the view – that is, above the slide show.  So make sure the Display Name speaks to administrators and developers and Title speaks to users and visitors.
  5. The next four blocks cover FORMAT, FIELDS, FILTER CRITERIA and SORT CRITERIA.
  6. Starting from the bottom — as those are easiest to understand – Sort Criteria telsl you the order in which slides will be displayed.  If you want to change the order, this will be the block where you will find the controls.
  7. Filter Criteria is also fairly self-explanatory:  with the default settings, the slideshow will only display published content that is an Article.
  8. The FIELDS block, if you followed the instructions for Screen 1, will be blank.
  9. FORMAT refers in the first line to Slideshow|Settings and Content|Teaser.  We will begin with Content and you will see that varying the Content changes your Field options in the Fields block below.
  10. Click on Content and choose Fields.  Now you see Content:Title come up below.  You can also Add a field.
  11. Add a field and you will see many choices.  Think a little – you are looking for Content: Image.  Add that, and it will come up in the Fields block.

Inspect Preview

Scroll down to the bottom of your screen.  You should see a slideshow of all the images that you have uploaded into Articles with the title of the Article above the Image.

Save and go to the menu where you linked the slideshow or type in the url to see your work on your website.

Advanced Option

You might also note that you are also seeing the title to every Article, whether it contains an Image or not.

To add a another Filter to choose only the Articles that contain an image, you can look first at the list of Filters.  I don’t think we will find a suitable filter because we are displaying nodes of content-type Article and we want a logic that would go something like “contains an image” rather than “is an image”. But look anyway.

(Remember to edit a View, go to Structure/Views.)

I went instead to Advanced Options and chose the Relationships. On that list I could find Content:Image (field). I added it and checked required.

Now my slideshow only contains Articles which contain an image.  And it is cycling nicely.  Save if you wish.

Slideshow Settings

What if I want to speed up my slideshow or add previous and next buttons?

Go back to the View and go to Slideshow | Settings in column one.  (Btw, if you have not downloaded jcycle correctly, on the following screen you will get a big warning message in red. So if something is not running correctly and you want to eliminate jcycle as being the cause look here.)

To get some basic settings, scroll down to the bottom and check the options under Bottom of the page.  Be patient as when you check the options, more options are revealed.

Oddly, the controls aren’t working as I expected them to.  I checked all three and checked the option to stop when hovering.  Only the counter is showing at the bottom for me.

Summary

So far, we have downloaded the correct modules and plugin and set up the basic slideshow view.

You know how to reveal fields and to add fields.  You know how to filter on the content-type (column 1) and on the fields (under Relationships in column three).  And you know where to find the settings to control the slide show.

You can also decide where your slideshow will go on you site – onto a page or block and if it is page, attached to a menu or not.

The next post will describe how to get the carousel working.