Add Honeypot to Simplenews subscription form block

The Drupal Honeypot module (https://drupal.org/project/honeypot) works well out of the box for comments and web forms in nodes.

In my case i needed to add the Honeypot spam filter to a Simplenews (https://drupal.org/project/simplenews) newsletter subscription form, which resides inside a block in the sidebar of most pages.

The problem here was that if the time restriction feature is active, the Honeypot module disables the cache on pages where it is used (which is on most pages). I could have disabled this feature all together, but it is just another layer of protection that i didn’t want to loose.

So the way to get around this is to target a specific form and add or alter the Honeypot feature specifically. This is done by creating a custom module.

Step by step

Create a folder in the module section (sites/all/modules), and give it the name of your module. Example: overwrite_simplenews

Add two files to the folder.

  1. overwrite_simplenews.info
  2. overwrite_simplenews.module

The .info file should contain something like this (change as required):

name = Overwrite Simplenews
description = Customization
package = Mail
core = 7.x

The .module file should contain something like this (change as required):

/* Add Honeypot to simplenews subscription form */

function kleinermann_form_alter(&$form, &$form_state, $form_id){
	if ($form_id == 'REPLACE_WITH_FORM_ID') {
		honeypot_add_form_protection($form, $form_state, array('honeypot'));
	}
}

You need to replace REPLACE_WITH_FORM_ID with the ID of the form you want to target. To find the form ID, you can check your page source in the browser with Firebug, or if the theme doesn’t output this information, you can use the Devel module. After activation of the Devel module, put this inside your module to output the form ID:

function kleinermann_form_alter(&$form, &$form_state, $form_id){
   dsm ($form);
   dsm ($form_id);
}

For more details check out this great video by Peter Yaworski: https://www.torontowebsitedeveloper.com/drupal-video-tutorials/drupal-6-simplenews-subscription-block-override-tutorial-1-2

If you check the form now in the source of your browser output you should find that there is an extra hidden field in your subscription form, named as specified in the Honeypot settings page.

How to customise and restore the Microsoft Word menu on Mac

If you need to make changes to the menu on Word you can rightclick onto the Toolbar and choose ‘Customise Toolbars and Menus…’

Remove, add or reorder menu items in the small menu on the top of the screen.

word-menu-2

Restore the original menu by clicking the reset button. Make sure you have highlighted the menu you want to reset before you push the button.

word-menu-3

How to Talk to a CentOS server via Command Line

Here are a few commands that I found helpful when I learned to use the command line to connect to the server.

Connect

To connect to the server, type the following line into your command line tool. I’m on a Mac and use the terminal:

ssh username@ip

username is the name of a user that has ssh permission, example: root. ip is the ip of the domain you want to connect to, example: 321.130.21.12

you will then be asked for a password for the user, which you need to provide.

Getting around

To manoeuvre to the right directory, you can use some of the following commands:

  • ls (list files and folders in the current directory)
  • cd (change directory)
    cd .. (change to parent directory)
    cd folder/folder1/folder2/ (go to a directory directly by typing the exact location)
  • use the ~ symbol to get back to the home directory. Example: cd ~

Doing things with files

You can manipulate files and folders by using the following commands.

cp
The cp command makes a copy of a file for you. For example, cp file foo makes an exact copy of the file whose name you entered and names the copy foo, but the first file will still exist with its original name. After you use mv, the original file no longer exists, but after you use cp, that file stays and a new copy is made.

mv
The mv command moves a file to a different location or renames a file. Examples are as follows: mv file foo renames the original file to foo. mv foo ~/Desktop moves the file foo to your desktop directory but does not rename it. You must specify a new filename to rename a file.

rm
Use this command to remove or delete a file in your directory. It does not work on directories that contain files.

mkdir
The mkdir command allows you to create directories. For example, mkdir music creates a music directory.

chmod
The chmod command changes the permissions on the files listed.
Permissions are based on a fairly simple model. You can set permissions for user, group, and world, and you can set whether each can read, write, and/or execute the file. For example, if a file had permission to allow everybody to read but only the user could write, the permissions would read rwxr–r–. To add or remove a permission, you append a + or a – in front of the specific permission. For example, to add the capability for the group to edit in the previous example, you could type chmod g+x file.

Example:

chmod 764 pics.html

owner group other
777 = rwxrwxrwx
755 = rwxr-xr-x
744 = rwxr–r–
644 = rw-r–r–

chown
The chown command allows the user to change the user and group ownerships of a file. For example, chown john file changes the ownership of the file to John.

How do I permanently delete my Facebook account?

I was quite surprised at how many hoops I had to jump through to permanently delete my Facebook account.

If you use the deactivation link from within your account preferences, the account is only deactivated and can be reactivated  at a later stage if you change your mind.

However, if you want to permanently delete your Facebook account, there doesn’t seem to be any way of doing so from within your account preferences.

I had to resort to searching for an external url via Google.

If you want to get off Facebook permanently, log into your account and use the following link:

https://www.facebook.com/help/delete_account

Add a new tab to a Facebook page (2012)

I had so many problems with adding a new tab to a Facebook page containing an iframe content from an external website, that I though i’d put this tutorial together for others who might be experiencing the same difficulties.

Requirements
In this tutorial I assume you have already set up or know how to set up the following things:

  1. Facebook Page
  2. Facebook Developer account
  3. URL to external website

The steps

Create New App: Go to https://developers.facebook.com/apps/ and create a new app. Then choose your app from the list and click the Edit App button on the top right.

Allow Tab feature: Scroll down the page and activate the Page Tab field. Here you need to fill in the name, url and secure url. The URL is the address to an external page (Example: https://www.my-website.com/facebook-landing-page). More and more users are using Facebook’s secure browsing feature. If you’d like to provide a page for these users as well, you’ll need to provide a url to a website with ssl security as well (Example: https://www.my-website.com/facebook-landing-page). Facebook actually requires this address now, but it is unclear what happens if you don’t provide it.

Activate the tab: At the time of writing,  there is no way to activate the tab other than using the link below. In the past, this was done by going on the application page. But since Facebook has gotten rid of his page, we need to use this link (replace YOUR_APP_ID with your apps id. This can be found in the url of your app).

https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&display=popup&next=https://www.facebook.com/

 

When you go to your Facebook page you should now see your new tab (If not, click the arrow on the right of your page to expose the second row of tabs – you might find your new tab there)

iPhoto Videos Don’t Work

Recently, I had the problem that videos on iPhoto wouldn’t play anymore on my Macbook pro (Snow Leopard 10.6.8). It took me quite a while to figure out the cause, so I thought i’d share my solution here.

Upgrade Quicktime

First, I uninstalled Quicktime by deleting it from the applications folder, and made sure I installed the latest version from here: Quicktime 7

This still didn’t fix the issue, but it’s probably still a good idea to make sure you’re runing the latest release.

Perian

Then I removed Perian, which I had installed a few months earlier. Perian is a collection of Quicktime components that add support for many popular video formats. I suspected that this may be causing the problem.

How to uninstall Perian

  1. Go to System preferences
  2. Click on Perian
  3. Click the uninstall button
  4. Go back to the system preferences overview page and right-click on Perian. Click on remove.
  5. Restart

When I restarted the Mac, the videos in iPhotos worked again. I don’t know why, but I think that the version of Perian I was running is what caused the issue. There might be other ways around it but I decided not to use Perian anymore and to simply install the codec components I needed manually instead.

Missing Codecs

I installed the XVid and DivX codec only, as they were the video formats I used primarily.

DivX can be installed from here.

And the XVid component can be downloaded from here. After the download, unpack and move the file to /Library/QuickTime.

 

 

How to Place WordPress Widgets Only on Certain Pages

By default, WordPress shows the same sidebar widgets on every page. If you need to hide widgets on certain pages, categories, post types, etc, you can use conditional tags.

In order to add conditional tags quickly and easily, you can use the Widget Logic plugin. Download it here: Widget Logic

This plugin adds an input field to every widget, where you can add the conditional tags.

In the example in the screenshot above, the Tag widget will only show on the post with ID 17.

If instead you would like to show the widget on all pages except the post with ID 17, you can put an ‘!’ at the start like this:

!is_single( '17' )

A list of all available conditional tags can be found on the WordPress codex site here.

How To Use MySQL On MAMP Via Terminal

I’m still quite new to the use of command line, so if there is any better way of doing this, please don’t hesitate to let me know in the comments.

To connect to your MAMP MySQL database via command line, first navigate to the correct directory within your MAMP installation using the Terminal (or another SSH client). Example:

 cd /applications/mamp/Library/bin

Then run the command to connect to MySQL (the default user and password are both ‘root’).
Example:

 mysql -u root -p

You should now see this:

mysql>

Update:
Here is a very nice post with some more details:
aschroder.com
And a list of terminal commands and their meaning:
ss64.com/osx/

Update:
To avoid typing the location of MySQL each time you open the terminal, you can set the location by default. Open the ‘bash_profile’ file in the user root:

 pico .bash_profile

Add the location of MySQL in a new line:

 export PATH=$PATH:/Applications/MAMP/Library/bin/mysql

Instructions on how to use the Pico editor here: ss64.com/osx/pico.html

Now you should get to MySQL simply by typing mysql into the terminal.

Ray White Real Estate

Ray White Real Estate is now launching a series of new websites for its offices in Australia. I have been involved in the front-end development as part of a team of very talented developers and designers. In my role as User Interface Developer, I was responsible for integrating the designs into the framework, and adding some of the fancy jQuery and CSS3 features.

Some of the first websites that have been launched are:

raywhitestkilda.com.au
raywhiteferntreegully.com.au
rwbyronbay.com

How to add or remove a www subdomain for Prestashop

Prestashop change url settingsLog into your admin interface, click on the Preferences tab, and on the SEO & URLs link one row below.

Scroll down to the area called URLs Setup, and look for the Shop domain name input field.

Here you can change the url to either use www (example: www.mydomain.com) or not (example:mydomain.com)

Now save your settings.

In order to make this work you need to let the server know about the change by updating the .htaccess file. This is done conveniently from within the Prestashop admin interface.

Prestashop generate .htaccess fileGo to the Tools tab and click on the Generators link one row below.

Then click the Generate .htaccess file button (If you can’t generate the .htaccess file from here, you will most likely be asked to change the write permissions for the file. You can do so for example via FTP).

Done.

Now you can go back to your shopfront and see if the changes took place.

x


Request a quote

I will get back to you within 24 hours.