David Slack - Web developer

Latest content

Helpful Code

I'll add some code snippets here that could help with a drupal website.

PHP

Add a class to each page

NB: This is for your custom theme, DO NOT add to one of the Drupal themes eg Garland. If you want to add a class to each page add this to the <body> tag of page.tpl.php:

A better Search with Finder

The Drupal in built search is ok for most things, but wouldn't you want something a bit better? How about a search that doesn't just search the titles? How about a list that appears as you type?

You can add some modules to do this, the first we will use is called Finder

Cron Job/Tab

The other problem is usually the cron job, this is a file called cron.php that needs to be run every hour. to save you going to it every hour of every day we create a cron tab or cron job that will do it for us. to do this open cPanel and log on:

Pathauto

Pathauto is a module to make your website use the page title instead of the node name for the URL.

For example, you could have www.example.com/node/3 or www.example.com/content/about-us . What is more descriptive of the content the page contains? Drupal has tools built in to change the URL on each page but wouldn't it be easier for you and you client if this was automatic?

Enter Pathauto, you can now create page and not worry about the URL.

Checking your website

Now your website is finished you'll want to check to make sure its fast and valid. Here are some tools to help find any problems.

W3C Validation

This site will tell you if your site is valid and if it's not will tell you why.

WebWait 

This site times how long it takes to access your site. Mine is 1.03 seconds but I'm testing some modules on other servers so I might be able to get that down.

File manager for WHM

Need a file manager for use with WHM? Try ConfigServer Explorer (cse) from the makers of CSF: http://www.configserver.com/cp/cse.html

To install or upgrade cse simply do the following from the root shell via SSH:

{syntaxhighlighter brush: applescript;fontsize: 100; first-line: 1; }rm -fv cse.tgz wg et http://www.configserver.com/free/cse.tgz tar -xzf cse.tgz cd cse sh install.sh cd .. rm -Rfv cse/ cse.tgz{/syntaxhighlighter}

Got a packet bigger than 'max_allowed_packet' bytes

So you tried to upload a database and got the error "Got a packet bigger than 'max_allowed_packet' bytes". This happens offten when you move a Drupal DB from one server to another.

So how do you make your server allow bigger packets? Easy.

There is a file in /etc called my.cnf. Simply add the line 'max_allowed_packet = 12M' to the end of the file (or edit the line) so the file reads:

Drupal 6 payment gateways with Ubercart

Here is a list of all the payment gateways I could find for Drupal 6 and Ubercart. A guy on Drupal called dalleyasaurus has done the same type of thing here, but with no links.

W3C

The site validated fine

Valid XHTML 1.0 Transitional

Valid CSS!

Privacy

I'll keep your data safe unless it is public, but I wont sell any of your data. Your password is safe, it's all hashed up so even I can't access it.

I'll get a better privacy statement up later.

PHP

At times I'll create functions or full programmes or find programmes others have written; this is the place I'll keep them.

cPanel and WHM

cPanel and WHM is the industry leader for turning standalone servers into a fully automated point-and-click hosting platform. It's a fully webbrowser based front end for your server.

Once you have installed centOS and have SSH access you can install cPanel with WHM and and that is it, your server is ready to use. 

Follow this guide to install

OR

To begin your installation, use the following commands:

Disability Discrimination Act

I've done my best to make sure the David Slack website works for most people most of the time. This means it should work with screen readers and other technology to help anyone with a disability read my website. If you find this isn't the case or can make this work with something that the site doesn't work with please contact me here.

davidslack.co.uk is W3C compliant in most cases so should be compliant with most technology

Install Configserver Security and Firewall on WHM

To help stop DOS (and to a certain extent DDOS) attacks we need a firewall. CSF (Configserver Security and Firewall) seems to be the most used on WHM.

Setup UploadProgress from WHM

Once you have cPanel/WHM installed and setup we want to ad a few modules to help it run. One of these is UploadProgress.

  1. Login to WHM
  2. Hit Home at the top left
  3. Hit 'Modules installers'
  4. Hit 'Manage' next to PHP Pecl
  5. Click the Show Available PHP Pecl(s) button
  6. Now search for 'UploadProgress' from the list (Ctrl+F)
  7. To the right of it hit the install button

All done!

If this works, great, but if not we've got to check out a few things.

 

SEO (Search Engine Optimisation)

SEO or Search Engine Optimisation is the black art of making your site easier for search engines to see and list. The better your SEO, the higher the site is ranked in the search engine. There are lots of ways of optimizing websites for search engines but here is how I do it.

Once you have the site optimised for Search engines you can start to market it with SEM and offline marketing.

Modules

As usual we need to add in some modules to extend the Drupal website. Lets start with these:

Displaying the Images

Now we need to tell the site how to display the files using our ImageCache presets. To do this click the 'Display fields' tab at the top. Now use the pull-downs to get the setting below

Images

  • Label = <Hidden>
  • Teaser = no styling
  • Full node = no styling

Main Image

CCK for images

Now we have the modules all installed and setup we'll go and make it so the user can upload an image on the page. You will have to do tis for each content type, but we will only do page and story for now

  1. Go to admin
  2. On the left click Content Types
  3. Click 'Manage Fields' to the right of 'Page'

Group

We'll add a group for our images so under New Group type Images in the box for Label and 'images' for the box for Group name now hit the Save button. Now to configure the group

ImageCache

Now to set up the main part of the image modules, we'll setup ImageCache

  1. Go to admin
  2. On the right hit 'ImageCache'

There will probably be only one preset for ImageCash at the moment and this is for the iTweak upload module. This preset will set up an images size for any image uploaded using iTweak upload. We won't touch this at the moment but we will create our own

From the image the user will upload we will create 4 images

Configuration

Once we have the modules installed we need to configure them

  1. First go to www.example.com/admin/settings/file-system/transliteration and click the Transliterate button if it asks you to. This will fix any problems with URLs you might have
  2. Click the 'Save configuration button
That's Transliteration setup, now Image API
  1. Go to admin
  2. Click ImageAPI on the right
  3. Make sure ImageAPI GD2 is selected
  4. Click the Save Configuration button

Now Lightbox2 to setup:

Pages

Latest content

There are lots of developers out there with varying degrees of experience and expertise, some mid level, some junior and some senior. Some...
First thoughts are Symfony is ace!Only been using Symfony for 1 project but the amount of coding it has saved has been worth the time spent...
The Lost and Found website was built by myself (David Slack) and designed by Arm & Eye.The site was created to promote a bar and...

Social networks

Contact me here or catch me on one of
the social networks below


What I'm listening to

My blog

Wednesday, 2 August, 2017 - 06:56
There are lots of developers out there with varying degrees of experience and expertise, some mid level, some junior and some senior. Some developers...
Tuesday, 5 March, 2013 - 09:49
First thoughts are Symfony is ace!Only been using Symfony for 1 project but the amount of coding it has saved has been worth the time spent learning...
Monday, 3 December, 2012 - 10:07
As a web developer and web designer I need to take into account everything on a site from SEO, marketing, usability across devices, the look and feel...

Try this on your mobile

Use your QR reader to read this

You should be able to use this right from the screen

Latest tweets

Calendar

M T W T F S S
1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11
 
12
 
13
 
14
 
15
 
16
 
17
 
18
 
19
 
20
 
21
 
22
 
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 
 
 
 
 
 

You are here

Back to top

Copyright David Slack - Web developer