How To Revive A ‘Dead’ WordPress Website

My old WordPress site http://basketball.exchange.ph was actively maintained for five years until I lost interest. After a few years of lying mostly dormant the site developed errors and essentially ‘died’ as it was inaccessible.

I wanted to reactivate it again. Fortunately I had not deleted the files and database from my shared server so making it ‘alive’ again was certainly possible. However since the site had not been updated for several years it was using a very outdated version of WordPress and was incompatible with the latest versions of MySQL and PHP.

Simply reactivating and updating it via the normal ‘one click update’ WordPress is known for is ok for most recently upgraded websites, but for those that haven’t been touched in years it may result in unwelcome surprises.

In summary, here’s what I did to avoid these surprises.

  1. Set up the old website to function the same way as it did before the domain lapsed.
  2. Set up a fresh new WordPress site with nothing in it.
  3. Use the Export tool on the old website to produce an xml file of old users, posts and comments.
  4. Import it into the new website.

Continue reading “How To Revive A ‘Dead’ WordPress Website”

Project Profile: School.Exchange.ph

SchoolEx

SchoolEx, evolved from the ‘School Directory’ portion of MomEx. All 5,100+ schools and 1,600+ comments were transferred over to the new site, and an additional 4,000+ public schools were added as well. The site now has 9,460 schools and counting in its directory, all of which are ready to be commented and rated on as usual.

The reason this was done is because MomEx wasn’t reaching its potential anymore. The School directory portion was still very strong however, and by itself was hitting 500 – 1000 visitors per day. Also, the underlying software was badly in need of a major update (it was made in 2006, and the most major update was 2010!), and was also starting to become a security worry.

A second more urgent reason was that MomEx was still using outdated Drupal 6 core and modules, which was a huge potential security risk. Here’s how its status page looked:

20160225_d6

Tech Used

Drupal 7 – Still my weapon of choice. Even with Drupal 8 well on its way I’d give Drupal 7 at least 5 to 7 years of active development still, and with migration modules having advanced as far as it has I’m sure it wouldn’t be very difficult to go to Drupal 8 when the time comes. Speaking of migration:

Migrate D2D – Migrate Drupal to Drupal is a dream to use, making transfer of nodes, taxonomy, pages, files, users, etc. as easy as clicking a few buttons. You will need a staging platform that’s an exact copy of the live host for it to work though, as the destination website opens the database of the source website to suck out its content. Previously you would have to do each task piece by piece which would probably make you want to tear your hair out. This task is best left for experts but once you know what you’re doing it can get easy.

Zen – I am a strong advocate of building off frameworks like the Omega and Zen theme and here I stuck to my guns. As a result I have a terrific responsive theme that’s easy to configure and read on most mobile screens as well. This was an enormous load off my back as the previous D6 Zen theme needed to be updated for the longest time as well as the core itself.

SchoolEx2

Two Challenges

• There were two challenges. Primarily it was vital that the comments would obviously come along with the nodes. The previous site’s comments held a wealth of information related to the school nodes they were attached to and if I lost them I would have essentially lost the value of the website itself. The initial migration attempts did not join the two and it turned out I had to transfer node and modules separately. It worked out eventually but I’m fairly sure there were a few that did not transfer. This may have been because the Drupal 6 source had also been a migration from WordPress sometime in 2008 or 09. I’m happy with the result anyway as the really good comments came later when it was already a Drupal 6 website.

• The second challenge involved making sure that the old website URL would execute a proper redirect. The old website enjoyed great SEO from searches of schools around the country, and I just wanted the ‘http://mom.exchange.ph’ part to change from ‘http://school.exchange.ph’, with the rest of the URL proceeding to the same page.

In other words I wanted:

http://mom.exchange.ph/school/makati/some-school-in-makati

to redirect to:

http://school.exchange.ph/school/makati/some-school-in-makati

I managed to do it with this .htaccess rule:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^mom\.exchange\.ph$ [NC]
RewriteRule ^ http://school.exchange.ph%{REQUEST_URI} [L,R=301,NE]
Options +FollowSymLinks

So now all traffic went directly to the correct site and to the correct page.

• A third semi – challenge involved the fantastic amount of spam the site immediately received once I got the URLs to properly redirect. I removed the Captcha module which proved useless and replaced it with google recaptcha, which immediately went to work blocking hundreds of thousands of spam.

So there you go I finally updated and transferred one of my most important websites to a better domain and an upgraded framework. I will be doing Kikay.Exchange.ph next.

‘The following module is missing..’ Drupal Error Messages After Update To 7.50

After updating your Drupal site from 7.44 to 7.50 you might see this message when you check your status report.

This happened to me. Below image explains that the admin should install the ‘webform’ module.

1

On another site, I also received the same message, this time looking for the ‘bestreply’ module. But since the error messages are set to ‘NONE’, it only displayed in the logs.

2

This also shows up when you use Drush:

3

Why is this happening?

According to the supporting page for this issue, there are three possible reasons:

  1. You removed a module from the file system without disabling and uninstalling it.
  2. You moved the module inside your Drupal installation.
  3. There is a bug in a module installed on your site.

Like most developers I do a lot of experimentation with modules I am not familiar with and in my case no. 1 definitely applied (you removed a module from the file system …). Sometimes I get confused with the number of attempts I do and I may delete a module without disabling it.

Why is this Necessary?

Removing a module without disabling it leaves a lot of ‘garbage’, eg. code that the module installed but is not necessary anymore. This may become a security risk. Third party modules are maintained independently from the core Drupal files and if the creators / people in charge of that module stop working on it, which occasionally happens, the code eventually becomes outdated and may allow malicious hackers access to other files or even the database.

It’s therefore appropriate to remove modules correctly by disabling it first. To learn more, read the part on the Changelog under ‘Improved performance (and new PHP warnings) when Drupal is trying to find a file that does not exist’

What to do?

The solution is very simple. Merely google the missing module and download it into the /sites/all/modules directory. In my case I didn’t even have to activate it and after checking the status page again the error message went away.

Conclusion

Always properly remove modules. And always read the Changelogs and Blogposts if any, to understand why things are happening the way they are. Version 7.44 to 7.50 represents a major jump as indicated by skipping over .45, .46, etc.. You should be at least even a little curious why that is so reading the Blogpost is extra important to keep updated and avoid surprises.

Project Profile: JSTLaw.net

JSTLaw.net is the website of Javier, Santiago, Torres Law Office located at Ortigas Center Pasig City, Metro Manila Philippines. I also made their previous website jstglaw.com.

jstlawnet01

This is a marked improvement from the previous site as it is now Responsive (ie. designed for ‘easy reading and navigation with a minimum of resizing, panning, and scrolling’). It also uses Modernizr.com script allowing an interesting rotating background of images I took of their office. It loads Javascript subject to the type of browser being used. It is also my first time to use Keyframe Animation Syntax to animate certain aspects.

jstlawnet02

Unlike a lot of Responsive sites I see today I didn’t go for a single page that usually scrolls to load other pages. My argument against this is that if, say, you want to load page 10, you have to load pages 1 – 9 before you get there, and that takes a lot of bandwidth and may confuse visitors.

Instead I went with the typical Menu approach where you click, via large menus, the page you want to load.

jstlawnet03

I think this is better that very long pages that involve a lot of scrolling. I like pages that load quickly and I like to help the user navigate to the page he wants without the browser loading all sorts of other things before it presents the information he’s looking for.

Estimated time to make: 4 weeks.

If you want a similar website done for you let me know via info@kaijuhost.com.

 

Drupal 7 Tutorial: Styling Comments Using Views

The default Recent Comments view in Drupal 7 lays out comments in this fashion:

1

Essentially it’s an unordered list (ul) featuring a clickable title of the comment followed by a comma, then a timestamp.

But what if you want the comment to include the name of the author and the name of the node as well, and to rearrange it?

Here’s how:

Step 1.

First, think of how you want the comment to look like and write it down. In the example below we are going to use in the following order:

  1. comment author followed by an
  2. @ sign, then the
  3. title of the node, a
  4. colon punctuation mark, followed by
  5. 96 characters of the comment (linked to the comment), then a
  6. timestamp with ‘ago’ appended.

Step 2.

Clone the ‘Recent Comments’ view in /admin/structure/views.

2

Step 3.

The default ‘Recent Comments’ only has the fields

‘Comment: Title’ and
‘Comment: Updated Date’.

We will add

‘Comment: ID’
‘Comment: Author’
‘(Content) Content: Title’
‘Global: Custom Text’

After some rearranging your fields should look like this:

3

Step 4.

  1. Click ‘Comment: ID’, then click ‘Exclude from Display’. Press Apply.
  2. Click ‘Comment: Title’ then click ‘Exclude from Display’. Press Apply.
  3. Click ‘Comment: Author’ then click ‘Exclude from Display’. Press Apply.
  4. Click ‘(Content) Content: Title’ then click ‘Exclude from Display’. Press Apply.
  5. Click ‘Comment: Updated date’ then click ‘Exclude from Display’. In the Date Format, choose ‘Time Span (with ‘ago / hence’ appended)’. Press Apply.
  6. Click ‘Comment: Comment’ then click ‘Exclude from Display’. Click ‘Rewrite Results’ and in the Link Path box, type ‘/comment/[cid]#comment-[cid]‘ like this:

    4

    Scroll down further and click ‘Trim this field to a maximum length’, and enter ’96’ at the Maximum Length box. Optionally, also click ‘Trim only on a word boundary’ and ‘Add an ellipsis’: Press Apply.

    8

  7. Click ‘Global Custom text’, and enter the following in the ‘Text’ box ‘[name]@[title]:</br>[comment_body]</br>[timestamp]‘ like this:5

Press Apply. The preview should now appear like this:

6

Click Save.

With some CSS styling you can come up with a snazzy looking sidebar comment list like this:

7

Drupal 8 Installation On a VPS

This was done on an Ubuntu 14.04 laptop (named groundcontrol). For all intents and purposes it is similar to a VPS. Just like a VPS it has MySQL, Php and Apache running a virtual host, all current versions as of this time.

This tutorial assumes you have set up your VPS appropriately, with the proper directories prepared, hosts file and DNS ready, etc.

I. Download and un-compress.

Go to Drupal.org, click ‘Download & Extend’

1

Click Drupal 8, right click the latest Drupal core 8.x and select ‘copy link address’.

2

Via SSH, login your VPS and go to the directory you set up for the installation. Here I used ‘/srv/www/d8’.

  • Enter ‘sudo wget’ then right-click your mouse to paste the address on the command line, ie.
sudo wget https://ftp.drupal.org/files/projects/drupal-8.1.1.tar.gz

The latest compressed drupal 8 files will download.

  • Uncompress the file
ghm33@groundcontrol /srv/www/d8 $ sudo tar xvzf drupal-8.1.1.tar.gz

The files will decompress into a folder called drupal-8.1.1.

  • Move all the compressed files in the new drupal-8.1.1 directory into public_html.
ghm33@groundcontrol /srv/www/d8 $ sudo cp -rv drupal-8.1.1/* public_html/

Enter the command ‘ls public_html/’ and you will now see all the drupal 8 directories and files properly laid out.

4

II. Prepare database.

Still in the terminal, login mysql.

sudo mysql -u root -p
  • Enter password to login mysql shell.
  • Create a database:
    create database d8;
  • Create a user and grant privileges to that user on d8:
    grant all on d8.* to 'd8user' identified by 'password';
  • flush priviliges;
  • quit

8

You now have an empty database (d8) and a database user (d8user). List this down.

III. Set up Drupal 8.

Open your browser and enter the url where you placed the drupal 8 files. This should appear:

9

After choosing a language, click ‘standard installation’ in ‘choose profile’.

10

A few errors appear.

  • Fix the clean URLs issue (the .htaccess file was not included when we copied it over).
 sudo cp -rv /srv/www/d8/drupal-8.1.1/.htaccess /srv/www/d8/public_html/
  • Fix the File System issue:
sudo mkdir -p /srv/www/d8/public_html/sites/default/files
  • Fix the Settings file issue:
sudo cp -rv /srv/www/d8/public_html/sites/default/default.settings.php /srv/www/d8/public_html/sites/default/settings.php

Refresh the page. You will probably see these messages:

11

  • Fix the file system issue:
 sudo chmod -R 777 /srv/www/d8/public_html/sites/default/files/
  • Fix the settings file issue:
sudo chmod 777 /srv/www/d8/public_html/sites/default/settings.php
  • Refresh your browser and proceed. Enter the database details prepared earlier.

12

Wait.

13

This message will appear:

14

Enter the ff. commands to fix these:

sudo chmod 444 /srv/www/d8/public_html/sites/default/settings.php

sudo chmod -R 755 /srv/www/d8/public_html/sites/default/files/

You should now have a working Drupal 8 installation.

15

Visit the ‘admin/reports/status’ page first and deal with any issues you find there. We will cover file and directory permissions in another post.

How To Rearrange Drupal Zen Theme Sidebars

Here’s how to rearrange sidebars on any Drupal v7.x website using the Zen theme 7.x.

After installing the Zen theme you will need to put some content onto a block and arrange it in admin/structure/block to appear on either sidebar left or right. In this example below I placed the Navigation Menu on the left sidebar region and the Search Box and Main Menu blocks in the Right sidebar region. By default the main content will appear in the middle:01_before

Let’s say you want to rearrange the layout so that from the left the main content will appear first, followed by the left sidebar and then the right sidebar. Here’s how to do it:

In the following examples we are editing a fixed layout, so you will edit the ‘themes/yourcustomtheme/css/layouts/fixed.css’ (Note: If you are using a responsive layout you will open the ‘themes/yourcustomtheme/css/layouts/responsive.css’).

In this image below, my theme name is ‘momex’, and I am using Notepad++ as my text editor.

02

Go to line 124, under the lines ‘Span 3 columns, starting in 2nd column from left’:

03

There are 3 elements:

  1. .two-sidebars #content selector shows attributes for the main content area.
  2. .two-sidebars .region-sidebar-first selector has attributes for the first sidebar and
  3. .two-sidebars .region-sidebar-second has attributes for the second sidebar.

Since we want the main content to appear on the left of the layout first, we switch the contents of item 1. (‘.two-sidebars #content”) and item 2. (‘.two-sidebars .region-sidebar-first’), like this. Don’t touch item 3 just yet.

04a

The result is like this:

05z

It looks awful yes, but at least we have the main content appearing on the leftmost column first, the ‘left sidebar’ appearing on the 2nd column and the third column where we want it to be.

We can now focus on the width of the left sidebar and the main content.

First we change item 1 (.two-sidebars) width from 176px to 568px, and item 2 (.two-sidebars .region-sidebar-first) from 568px to 176px:

06

Now there’s a huge gap between the first and second sidebar. This is because of the margin-widths of both the first and second sidebars.

So for item 2 (.two-sidebars .region-sidebar-first) we change margin-left from 0 to 196px and margin-right from -196px to -392px.

And for item 3. (.two-sidebars .region-sidebar-first) we change margin-left from 784 to 392px and retain margin-right at -930px.

Voila.
07

Here’s the final css for the FIXED layout code:

/* Span 3 columns, starting in 1st column from left. */
.two-sidebars #content {
 float: left;
 width: 568px;
 margin-left: 0px;
 margin-right: -196px;
 
}

/* Span 1 column, starting in 1st column from left. */
.two-sidebars .region-sidebar-first {
 float: left;
 width: 176px;
 margin-left: 196px;
 margin-right: -392px;
 background-color:#e0e0eb;
}

/* Span 1 column, starting in 5th column from left. */
.two-sidebars .region-sidebar-second {
 float: left;
 width: 176px;
 margin-left: 392px;
 margin-right: -980px;
 background-color:#cbd1d1;
}

And as a BONUS, here is final css for a RESPONSIVE layout with same results, starting on line 249 in the /themes/yourcustomtheme/css/layouts/responsive.css

/* Span 3 columns, starting in 1st column from left. */
 .two-sidebars #content {
 float: left;
 width: 60%;
 margin-left: 0%;
 margin-right: -20%;
 }

/* Span 1 column, starting in 1st column from left. */
 .two-sidebars .region-sidebar-first {
 float: left;
 width: 20%;
 margin-left: 20%;
 margin-right: -40%;
 background-color:#e0e0eb;
 }

/* Span 1 column, starting in 5th column from left. */
 .two-sidebars .region-sidebar-second {
 float: left;
 width: 20%;
 margin-left: 40%;
 margin-right: -100%;
 background-color:#cbd1d1;
 }

Notes:

  • The standard width of the fixed layout is 960px, and this value is key to figuring out the margin-widths.
  • Issuing unique background-colors to your sidebar css helps greatly in distinguishing one from the other.
  • Doing same for a responsive theme is similar if not easier because it uses percentages rather than pixels.

 

 

 

How To Set Up Reverse DNS On Linode

Once you set up a VPS on Linode you will also need to set up email by installing a Message Transfer Agent such as Sendmail or Postfix. If you do not set up Reverse DNS however, your webserver will not be able to send out email, and if you send out an email to a gmail address gmail will send your server a message like this:

050 550-5.7.1 [2600:3c03::f03c:91ff:feb0:dac3] Our system has detected that this
050 550-5.7.1 message does not meet IPv6 sending guidelines regarding PTR r ecords
050 550-5.7.1 and authentication. Please review
050 550-5.7.1 https://support.google.com/mail/?p=ipv6_authentication_error for more
050 550 5.7.1 information. b87si2979083qkb.118 – gsmtp

Checking https://support.google.com/mail/answer/81126?p=ipv6_authentication_error&rd=1#authentication will bring you this page, which explains the error as your server not having a ‘reverse dns’, or the association of a domain name with an IP address.

To fix this on Linode, login to Manager.linode.com, and click the ‘Remote Access’ tab.

  • On Public IPs, click ‘Reverse DNS’
  • Enter a hostname, and once you click Look Up this page will appear, such as on mine where I want to associate my IP addresses (both ipv4 and ipv6) to the hostname ‘majortom.kaijuhost.com’.

04

  • Click ‘YES’ to either. If you wish to add the other as well, repeat the process. Wait 24 hours for the DNS to fully spread around the ‘net.

More information here.

Fastest Way To Batch Change Authors On Drupal 7

Step 1.

import ‘batch_change_content_author’ view from here, or cut and paste the code below. Required modules are Views and Views Bulk Operations:

$view = new view();
 $view->name = 'batch_change_content_author';
 $view->description = '';
 $view->tag = 'default';
 $view->base_table = 'node';
 $view->human_name = 'Batch change content author';
 $view->core = 7;
 $view->api_version = '3.0';
 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
 /* Display: Master */
 $handler = $view->new_display('default', 'Master', 'default');
 $handler->display->display_options['title'] = 'Batch change content author';
 $handler->display->display_options['use_more_always'] = FALSE;
 $handler->display->display_options['access']['type'] = 'perm';
 $handler->display->display_options['cache']['type'] = 'none';
 $handler->display->display_options['query']['type'] = 'views_query';
 $handler->display->display_options['exposed_form']['type'] = 'basic';
 $handler->display->display_options['pager']['type'] = 'full';
 $handler->display->display_options['pager']['options']['items_per_page'] = '50';
 $handler->display->display_options['style_plugin'] = 'table';
 /* Relationship: Content: Author */
 $handler->display->display_options['relationships']['uid']['id'] = 'uid';
 $handler->display->display_options['relationships']['uid']['table'] = 'node';
 $handler->display->display_options['relationships']['uid']['field'] = 'uid';
 /* Field: Bulk operations: Content */
 $handler->display->display_options['fields']['views_bulk_operations_1']['id'] = 'views_bulk_operations_1';
 $handler->display->display_options['fields']['views_bulk_operations_1']['table'] = 'node';
 $handler->display->display_options['fields']['views_bulk_operations_1']['field'] = 'views_bulk_operations';
 $handler->display->display_options['fields']['views_bulk_operations_1']['label'] = '';
 $handler->display->display_options['fields']['views_bulk_operations_1']['element_label_colon'] = FALSE;
 $handler->display->display_options['fields']['views_bulk_operations_1']['vbo_settings']['display_type'] = '1';
 $handler->display->display_options['fields']['views_bulk_operations_1']['vbo_settings']['enable_select_all_pages'] = 1;
 $handler->display->display_options['fields']['views_bulk_operations_1']['vbo_settings']['force_single'] = 0;
 $handler->display->display_options['fields']['views_bulk_operations_1']['vbo_settings']['entity_load_capacity'] = '10';
 $handler->display->display_options['fields']['views_bulk_operations_1']['vbo_operations'] = array(
 'action::node_assign_owner_action' => array(
 'selected' => 1,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::views_bulk_operations_delete_item' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::views_bulk_operations_delete_revision' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::views_bulk_operations_script_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::flag_node_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_make_sticky_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_make_unsticky_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::views_bulk_operations_modify_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 'settings' => array(
 'show_all_tokens' => 1,
 'display_values' => array(
 '_all_' => '_all_',
 ),
 ),
 ),
 'action::views_bulk_operations_argument_selector_action' => array(
 'selected' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 'settings' => array(
 'url' => '',
 ),
 ),
 'action::node_promote_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_publish_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_unpromote_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'rules_component::scheduler_remove_publish_date_component' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'rules_component::scheduler_remove_unpublish_date_component' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_save_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::system_send_email_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'rules_component::scheduler_set_publish_date_component' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'rules_component::scheduler_set_unpublish_date_component' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_unpublish_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::node_unpublish_by_keyword_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 'action::pathauto_node_update_action' => array(
 'selected' => 0,
 'postpone_processing' => 0,
 'skip_confirmation' => 0,
 'override_label' => 0,
 'label' => '',
 ),
 );
 /* Field: Content: Title */
 $handler->display->display_options['fields']['title']['id'] = 'title';
 $handler->display->display_options['fields']['title']['table'] = 'node';
 $handler->display->display_options['fields']['title']['field'] = 'title';
 $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
 $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
 /* Field: User: Name */
 $handler->display->display_options['fields']['name']['id'] = 'name';
 $handler->display->display_options['fields']['name']['table'] = 'users';
 $handler->display->display_options['fields']['name']['field'] = 'name';
 $handler->display->display_options['fields']['name']['relationship'] = 'uid';
 $handler->display->display_options['fields']['name']['label'] = 'Current author';
 /* Sort criterion: Content: Post date */
 $handler->display->display_options['sorts']['created']['id'] = 'created';
 $handler->display->display_options['sorts']['created']['table'] = 'node';
 $handler->display->display_options['sorts']['created']['field'] = 'created';
 $handler->display->display_options['sorts']['created']['order'] = 'DESC';
 /* Filter criterion: Content: Published */
 $handler->display->display_options['filters']['status']['id'] = 'status';
 $handler->display->display_options['filters']['status']['table'] = 'node';
 $handler->display->display_options['filters']['status']['field'] = 'status';
 $handler->display->display_options['filters']['status']['value'] = 1;
 $handler->display->display_options['filters']['status']['group'] = 1;
 $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
 /* Filter criterion: Content: Author uid */
 $handler->display->display_options['filters']['uid']['id'] = 'uid';
 $handler->display->display_options['filters']['uid']['table'] = 'node';
 $handler->display->display_options['filters']['uid']['field'] = 'uid';
 $handler->display->display_options['filters']['uid']['value'] = '';
 $handler->display->display_options['filters']['uid']['exposed'] = TRUE;
 $handler->display->display_options['filters']['uid']['expose']['operator_id'] = 'uid_op';
 $handler->display->display_options['filters']['uid']['expose']['label'] = 'Filter by author';
 $handler->display->display_options['filters']['uid']['expose']['operator'] = 'uid_op';
 $handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid';
 $handler->display->display_options['filters']['uid']['expose']['remember_roles'] = array(
 2 => '2',
 1 => 0,
 4 => 0,
 3 => 0,
 17 => 0,
 7 => 0,
 6 => 0,
 8 => 0,
 9 => 0,
 10 => 0,
 11 => 0,
 12 => 0,
 13 => 0,
 14 => 0,
 15 => 0,
 16 => 0,
 );
 /* Display: Page */
 $handler = $view->new_display('page', 'Page', 'page');
 $handler->display->display_options['path'] = 'admin/content/batch-change-author';
 $handler->display->display_options['menu']['type'] = 'normal';
 $handler->display->display_options['menu']['title'] = 'Batch change content author';
 $handler->display->display_options['menu']['name'] = 'management';
 $translatables['batch_change_content_author'] = array(
 t('Master'),
 t('Batch change content author'),
 t('more'),
 t('Apply'),
 t('Reset'),
 t('Sort by'),
 t('Asc'),
 t('Desc'),
 t('Items per page'),
 t('- All -'),
 t('Offset'),
 t('« first'),
 t('‹ previous'),
 t('next ›'),
 t('last »'),
 t('author'),
 t('- Choose an operation -'),
 t('Title'),
 t('Current author'),
 t('Filter by author'),
 t('Page'),
 );

To import a new view, go to ‘/admin/structure/views/import‘, enter any view name and paste the code above.

1

Once imported you will now have the new view.

2

Step 2.

Just visit the path indicated in the Page Settings, which would be admin/content/batch-change-author.

Step 3.

Perform the steps as needed to change the author of your content.

3z

Notes:

  • Views Bulk Operations (VBO) along with Views are required modules for above operation to work.
  • Changing authors en masse is a crucial step if you are removing users from your Drupal website. You can individually remove users via admin > People > Cancel > Delete, however that can be taxing if you are removing a lot of users.
  • Drush User Cancel (drush ucan) is a good alternative to removing users albeit one by one although it will not let you choose what will happen to orphaned nodes. By default any nodes authored by the canceled user will be changed to ‘anonymous’.

Relevant Content Is What Makes A Successful Website

 

Here’s a great example of how you can make your website relevant.

Gov.ph upped its game by uploading all the information we normally require from the government, such as ‘how to get an SSS membership’, or ‘how do I renew my driver’s license’, and so forth, into one page.

govph02

Of course you may say, well that’s what they’re supposed to be doing anyway, right? Well if so they could have just provided a link to, say, the Land Transportation Office (LTO) website for motor vehicle registration, and they’d already be ‘helping’.

But they didn’t stop there. They basically copied that information and placed it in its own section of their website so that it sits along with all other important info like how to get a passport, how to get NBI clearance, and so forth, thereby producing an ‘all in one’ go to place so you only need to go to that website whenever you need any info from the government.

govph01

As a result their website will get visits and become RELEVANT (the key word here), to people’s lives. Remember this example when making your own.