My Idea for LGUs: Online Village Sticker Administration

Every year small to large villages called barangays, villages or LGUs (Local Government Units) all over the Philippines issue annually renewed stickers to the public allowing entry into their villages. Tenants pay a regular fee while non – tenants are charged more for the privilege, a common practice for villages used as shortcuts for drivers to skip traffic or are home to schools or offices that non tenants need to visit.

Annual renewal is an arduous process especially for larger villages and the process is akin to car registration renewal – yet another one of the many annoying things car owners have to go through. I always thought IT could help so here’s a web based facility that may automate the process:

Sign Up and fill up a Profile

Here is the sign up process:

  1. Tenant or Not?
  2. Business or Individual?
  3. Full name / Company / Organization Name
  4. Date of Birth
  5. Address
  6. Gender
  7. Mobile / Telephone Number
  8. Government ID (Driver’s License, Passport, etc.); or DTI / Mayor’s Permit

Continue reading “My Idea for LGUs: Online Village Sticker Administration”

Government IT Idea: Centralized Document Clearing House

After a few years working at different government agencies I’ve come up with a few ideas. Some I thought of myself, many from discussion with consultants like myself, some seen from abroad, etc. I’ll be writing at least one per week, starting with this one:

Idea: Centralized Document Clearing House

THE PROBLEM:

Government agencies send hardcopy letters, memos, invitations, official papers and all sorts of documents to each other all the time. The potential for fraud is medium to high especially for example when LGUs write to ask support from government agencies and Congressmen or Senators for regional projects ie. bridges, buildings, medical facilities and all sorts of infrastructure. Continue reading “Government IT Idea: Centralized Document Clearing House”

‘Jargon – Free Contract’ Boils Down What An Agreement Really Is

I like this ‘jargon free contract‘ I saw recently from Boingboing.net, which I copy here:

You give me money, I’ll give you creative.
I’ll start when the check clears.
Time is money. More time is more money.
I’ll listen to you. You listen to me.
You tell me what you want, I’ll tell you what you need.
You want me to be on time, I want you to be on time.
What you use is yours, what you don’t is mine.
I can’t give you stuff I don’t own.
I’ll try not to be an ass, you should do the same.
If you want something that’s been done before, use that.
PRO BONO
If you want your way, you have to pay.
If you don’t pay, I have final say.
Let’s create something great together.

It’s enjoyable because for the most part this boils down my own experiences as a Consultant and Freelancer and more importantly how it relates to expectations while executing work.

Continue reading “‘Jargon – Free Contract’ Boils Down What An Agreement Really Is”

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.