Tuesday, December 30, 2008

Converting a Drupal 5.x module to 6.x

1) Edit .info file
Add the following line:

core = 6.x

which should match the value of DRUPAL_CORE_COMPATIBILITY defined in modules/system/system.module
Change

dependencies = module_a module_b module_c

to

dependencies[] = module_a
dependencies[] = module_b
dependencies[] = module_c

2) Update hook_menu()

http://drupal.org/node/103114

3) Update to new Form API
Includes the hooks hook_elements(), hook_forms()

any calls to the functions drupal_get_form(), drupal_retrieve_form()

and any use of the array keys #submit, #validate, #process, #multi_step, #base, #pre_render

http://drupal.org/node/144132

4) hook signature changes:
function mymodule_form_alter($form_id, &$form)
becomes
function mymodule_form_alter(&$form, $form_state, $form_id)

function mymodule_help($section) { switch ($section) {
becomes
function mymodule_help($path, $arg) { switch ($path) {
5) Other substitutions
url($path, $query, $fragment, $absolute)
becomes
url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => $absolute));
If you know for sure that your $path does not need to be looked up in the URL alias table, you can also add 'alias' => TRUE to boost performance$attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE)
l($text, $path, $attributes, $query, $fragment, $absolute, $html)
becomes
l($text, $path, array('attributes' => $attributes, 'query' => $query, 'fragment' => $fragment, 'absolute' => $absolute, 'html' => $html));
If you know for sure that your $path does not need to be looked up in the URL alias table, you can also add 'alias' => TRUE to boost performance
6) No longer supported:
db_num_rows() is gone. Count the rows yourself while iterating through the result set, or run a COUNT(*) SQL query.

--------------------------------------------------------------------------------

If your module defines a custom node
hook_access() $account parameter
Add $account as the third parameter to hook_access()
Get rid of global $user references and replace them with $account
Add $account as a second parameter to all calls to user_access()
update hook_form() to use Drupal 6 form api
Replace your hook_submit() with extra code in hook_form()


--------------------------------------------------------------------------------

If your module defines custom form elements

Move theme_elementname to elementname.tpl.php
Create a hook_theme()
Create a hook_theme entry for each custom form element, and load admin/build/modules to get drupal to call your new hook_theme()

(Optional) Add arguments to your #process function.
The #process function signature is now process($element, $edit, $form_state, $complete_form)


--------------------------------------------------------------------------------

If your module has its own database tables
(Optional) Switch to the Schema API.

--------------------------------------------------------------------------------

If your module defines theme functions / themeable hooks
Create a hook_theme() function which tells Drupal about your theme functions, as they are no longer discovered automatically.


--------------------------------------------------------------------------------

Optional Changes
A) (Optional) Clean up detection of which menu handler is active
Code which calls arg() to determine the current menu handler can be replaced with a call to menu_get_item().

For example:
if (arg(0) == 'node' && is_numeric(arg(1)) && ($node = node_load(arg(1))))
{
}

can sometimes be replaced with something along the lines of:
$menu_item = menu_get_item();
if ($menu_item['path'] == 'node/%' && ($node = menu_get_object()))
{
}
(runs on node/1234 but not node/1234/edit)

or:
if ($node = menu_get_object())
{
}
(runs on all node pages where the node id is arg(1), even if arg(0) is not 'node')

Drupal : Move the Login Block to newly Created Page

As the new page has been created the Login block may be moved to it. The block administration page can be found under Administer -> Site building-> Blocks. To move the login block to the page created in the previous step find User login in the list of blocks, then click configure.

Under Page specific visibility settings select the Show on only the listed pages option, then enter ‘login’ into the Pages text box. ‘login’ is the name of the page where the block should be displayed; more than one page can be listed by pressing return between page names (see the instructions on the block configuration page, underneath the Pages text box for details). Click Save block to complete the changes.

When the block is saved Drupal returns to the block listing page, finally the block should be moved from the side bar to the content area of the page. Under Region in the block list are a column of drop-down menus: using the drop-down for User login select Content, then click Save blocks. The login block should have successfully been moved, all that remains is to test the changes: particularly important as hiding the login block would be disastrous!

R.Navaneethakrishnan
http://navaneethakrishnan-drupal.blogspot.com/

Drupal: Custom Drupal Home Page: the Complicated Way (With Views)

For a home page with dynamic content (latest article summaries, top ten articles, etc.) it is better to use a view. Views can be used to create both pages and blocks. This section will show both: first a page view will be created, then a block view added to that page, giving an overview of how to create truly customized home pages for Drupal.

1.
Download and Enable the Views Module

Firstly download the Views module from the Drupal website.

Since Drupal 5 the best place to keep modules is drupalinstalldirectory/sites/all/modules (where ‘drupalinstalldirectory’ is the directory Drupal is installed in, e.g. httpdocs or public_html). If the directory does not exist: create it. Storing modules in this location keeps them separate from the ones that come with Drupal. Making upgrades and safely removing modules easier. No more: ‘Was that module part of Drupal?’

Upload the whole views directory to the Drupal site, the path of the module should look like: drupalinstalldirectory/sites/all/modules/views. Then enable it under Administer -> Site building -> Modules on the Administrators menu (in the side bar of a default Drupal installation) by finding the Views group, selecting the Views and Views UI check boxes, then clicking Save configuration, at the bottom of the page.
Optional Video: Installing the Views Module

The embedded video shows how to install the views module. This is in Flash format, which is non-Free and patent enclubered, not all surfers will be able to view it. For these users an OGG video is available.
#
Create a New Page View

Click Administer -> Site building -> Views this will show a list of currently available views, the module comes with some ready made ones, but this article will show how to make a new page view from scratch.

Click Add at the top of the views page, then enter: ‘first_three_teaser’ as the Name.

Drop down the Page group and check the Provide Page View.

Under the URL text box enter ‘firstthree’.

Select Teaser List from the View Type list. This shows a short summary of the articles/blog posts in the site database, views allow up to 99999 posts per page (should be enough for any site)! In this case three will be shown, with no pager (widget to move between pages).

Make sure Use Pager and Breadcrumb trail should not include "Home" are both not checked, then enter 3 in the Nodes per Page text box.

Next Filters are used to ensure the view includes only articles published and promoted to the front page by an administrator. Expand the Filters group by clicking on it.

Using the Add Filter drop-down list select Node: Published, then Add Filter. Repeat this with Node: Front Page.

The article teasers need to be ordered by the date they were written. Expand the Sort Criteria group. Using the Add criteria drop-down select Node: Created time, then click Add Criteria. Note that the order of the criteria needs to be changed so the articles published last are listed first, to do this change the Order drop-down list to Descending.

Lastly click Save. The new view has been created!
#
Make Drupal Use the New View as its Front Page

Select Administer -> Site configuration -> Site information in the Drupal administrator menu. Enter ‘firstthree’ in the Default front page text box.

Click Save configuration. Return to the front page (usually by clicking the site logo) and check the changes are working, if there is no content on the site enter some by clicking Create content -> Story in the administrator menu. Anything can be entered here, silly posts can be deleted later!
#
Add Blocks to Taste

Creating a page View is only the beginning. Views allow almost all the information on a site to be grouped, summarised and ordered in ways visitors might like. Blocks are small bits of content in Drupal, they can be inserted into a page at several predefined places (see Administer -> Site building -> Blocks to configure blocks). This tutorial shows how to create two blocks, the first produces a table of the 10 newest articles, the second a table of the 10 most commented on articles.
10 Newest Block

Select Administer -> Site building -> Views in the Drupal administrator menu, then click Add in the menu at the top of the page.

Enter ‘newest10’ as the view Name.

Expand the Block group and check the Provide block box.

Under the View Type drop-down select Table View, enter ‘10 Newest’ in the Title and ‘10’ in the Nodes per block.

Leave the Block group and expand the Fields one. Then—as creating a page view, using the Add field drop-down—add the following fields to the block:

* Node: Title
* Node: Author Name
* Node: Created Time

Next to the Name is a Label field, this is used for column headings in the view generated table. Node: Title should have a Label of ‘Title’, Node: Author Name should be ‘Author’ and Node: Created time should be labelled ‘Date’.

Expand the Filters group by clicking on it. Using the Add Filter drop-down list select Node: Published, then Add Filter. Repeat this with Node: Front Page. These are the same filters used on the page view.

Lastly the items in the table need to be ordered by the date they were written. Expand the Sort Criteria group. Using the Add criteria drop-down select Node: Created time, then click Add Criteria. Then change the Order drop-down list to Descending. This sort is the same as that on the page view created earlier in this article. Click Save to finish creating the block.
10 Most Commented Block

Follow the instructions above, for creating the 10 newest block, with the following changes:

* For the view Name enter ‘mostcommented10’;
* Under the block Title enter ‘10 Most Commented On’;
* Instead of clicking Save when finished, click Save and edit.
* Visitors may wish to know how many comments are attached to each article in the table. To do this add the field: Comment: Count to the block view (in the same way all other fields were added).

Making this into the 10 Most Commented On block is just a case of adding another Sort Criteria. Select Comment: Comment Count in the Add Criteria drop-down list, then click Add Criteria. Notice the Node: Created Time criteria is above the one just created, click the up arrow of the comment count line to move it above this. Change the sort order by selecting Descending in the Order drop-down list.

Finally click Save.
Showing the Blocks on the Front Page

Repeat these steps for each block. The block administration page can be found under Administer -> Site building-> Blocks. Click configure on the block that needs to be moved.

Under Page specific visibility settings select the Show on only the listed pages option, then enter ‘’ into the Pages text box. ‘’ is the name of the page where the block should be displayed; more than one page can be listed by pressing return between page names (see the instructions on the block configuration page, underneath the Pages text box for details). Click Save block to complete the changes.

When the block is saved Drupal returns to the block listing page, finally the block should be enabled and moved to the content area of the page. Under Region in the block list are a column of drop-down menus: using the drop-down select Content, then click Save blocks.
#
Optional Video: Creating Page and Block Views

The embedded video shows how to carry out the steps above to create both page and block views. Helpful if something some part of this tutorial is difficult to understand, missing something, or Drupal isn't working the way it should. This is in Flash format, which is non-Free and patent enclubered, not all surfers will be able to view it. For these users an OGG video is available.
Conclusion

Views are one of the most versatile and useful modules available for Drupal, this article can only scratch the surface of what is possible with them. The best way to learn is by creating views, then changing them until they provide exactly what the visitor wants. It's also worth noting that other modules for Drupal can integrate with views: providing more information.

Often a simpler site will not require views at all, using a static page is simple yet effective. Dynamic sites don't need to look dynamic, Drupal caters for this taste too

Drupal : Custom Drupal Home Page: the Simple Way (Without Views)

The simple way to customize Drupal offers the least flexibility but is, of course, easier. For people who need only a static page this will work well. Those looking for more complicated, dynamic content on their front page (summaries of most popular content, most recent articles etc.) should skip to the section showing the complicated way (it's complicated but, thanks to step-by-step instructions, not difficult!).

1.
Create a New Page

Select Create Content -> Page in the Drupal administrator menu (in the side bar of a default installation).

Enter at least a Title, e.g. ‘Home Page’. Text in the Body is optional (and can be added later).

Click to drop-down URL path settings, then enter ‘home’ in the text box. Also drop-down Publishing options and ensure Published is checked but Promoted to Front Page is not.
2.
Make Drupal Use the New Page as its Front Page

Under the administrator menu, select Administer -> Site configuration -> Site information.

Change Default home page to ‘home‘, then click Save configuration.

Finished! Click the site logo (or type in the URL) to go to the newly created home page. To edit the text on the home page simply click the Edit link, when logged in as an administrator.

Monday, December 29, 2008

Drupal Successful SEO Begins With Keyword Research and Analytics

Many webmasters / online marketers make a common mistake when they begin doing business online. Often times, people do the processes necessary for their success - backwards. Rather than starting at the beginning and working forwards, they start at the end and work backwards. As a result, they waste more money and resources, often breaking the back of their business, well before they start to see any real success in their business.

In my years of helping online marketers promote their businesses, I have seen business models that seemed to have all of the elements necessary to ensure great success. And unfortunately, I have seen many of these perfect business models fail miserably, because their owners failed to honor their business with a realistic promotional plan.

Putting The Cart Before The Horse

When people begin to promote their new business, this is where most people begin to err.

Just recently, I spoke with an individual who started a business in a pretty competitive field. I don't view heavy competition as being a bad thing. In fact, I find that there are often enough customers in any niche to support the additional competitors, especially when a new competitor answers a need not served by the current players.

The individual to whom I refer made his mistake by focusing 95% of his advertising budget on Search Engine Optimization (SEO), before he even knew what keywords would help him to be profitable in his business! He has so far blown $9,500 of his $10,000 to optimize his website for the search engines, and he still does not know what keywords will drive traffic to his website, leading to sales conversions for his website.

His "backwards" approach has left him with only $500 in his budget, with little hope for his future. He now emails me 4-5 times a week, always in a state of utter panic for the prospect of his future. All I can tell him is to be patient, since he has to learn how to "bootstrap" his way to success, now that he has no budget left to build strong and fast.

Test Your Copy First

Search Engine Optimization should "never" be a business' first step in the promotion process. Although SEO can bring great rewards, it can also be very expensive to implement. Look at it this way. What good is search optimization if you have optimized for the wrong keywords?

The first step in the promotion of any business should be focused on attracting potential customers to one's website.

The marketer needs to put human eyeballs on the website, so that they can test and tweak their sales copy for greater sales conversion.

Until a website has seen several hundred visitors, the sales copy should not be changed or tweaked. Sales copy should always be tested against a large statistical group of visitors, in order to ensure that the copy is given a fair and realistic test.

If the online marketer has a bit more money to start the process, often the best spent money will be to hire a professional copywriter to write the sales copy for the website. Professional copywriters have a skill, and that skill is to create the words that will drive people to buy what you are selling.

Test Traffic Is Important To The Process

Most Internet Marketing newbies are still focused on getting those first few hundred visitors to their websites.

At this point, there are systems like Link Referral and Traffic Swarm that can help the new business owner bring in a bit of traffic to their website. In a test with Link Referral, I am seeing 250 visitors per month. The neat thing about systems like these is that other members will review your website and offer good advice on how to improve your website, if necessary. Membership is free for both systems, with an option for paid upgrades.

The Law Of Attraction

While the traffic exchange systems mentioned above can send some traffic to your website, you are not going to get rich participating in those systems.

Once you have positioned your website to convert visitors to buyers, it is time to start attracting a larger number of visitors (potential customers) to your website.

There are a number of ways to do this, but two of the most effective are: Article Marketing and Pay-Per-Click Advertising.

Article Marketing

Mark Silver recently produced an exceptional home study course about writing articles that will help you be much more successful in your article marketing activities (http://thephantomwriters.com/heartofarticlemarketing).

Just last week, a friend of mine told me that he has not promoted his website in over a year, yet he noticed that his website has a steady stream of traffic to it, from the three-dozen articles that he wrote and distributed in 2006 and 2007. He said that his ebook continues to produce new sales each and every month, and the only thing he can really attribute those continuing sales to is the articles that are available on the Internet that are promoting his website and ebook.

Article marketing, in and of itself, is a promotional tool that will allow a marketer to bring regular visitors to his or her website, and if the website does its job well, then the website will be able to convert those visitors to buyers. This is important, because all businesses need money coming into a website early, to ensure that the business can survive financially, until the long-term "recipe for profit" can be found and duplicated reliably.

Pay-Per-Click Advertising

Pay-Per-Click (PPC) advertising is a process where you bid on keywords in the major search engines, through Google Adwords, Yahoo Search Marketing, etc. You tell the search engine companies what words you desire to bid on and how much you are willing to pay for a visitor, and the highest bidders for that keyword phrase will be shown above and to the right of the free results in the search engine results pages.

Keyword research, utilizing systems like Word Tracker, or my favorite, NicheBot will enable you to brainstorm keywords and get a good idea of which keywords might be more profitable for your business.

By utilizing Google Analytics or Yahoo's Panama Full Analytics (traffic analysis), an online marketer can follow a visitor from the search engine to the marketer's sales page. Where this is important is it enables an online marketer to uncover the essential business knowledge of which "keywords" will bring people into a website and help convert those visitors into customers.

Essential SEO Knowledge

What one must keep in mind is that some keywords will deliver visitors who will never buy, while other keywords will deliver visitors who are extremely likely to buy. This one paragraph holds within it the secret to a successful SEO strategy. This is the essential knowledge that a marketer should have, before engaging in any Search Engine Optimization campaign.

Like I said previously in this article, "Although SEO can bring great rewards, it can also be very expensive to implement."

If you are going to spend a lot of money to optimize your website for the search engines, doesn't it make much more sense to target the keywords that will actually help you to earn back your investment?

The Backwards Thinking

The backwards thinking I referred to in the beginning of this article was the idea that many people put SEO in front of their keyword research, keyword tracking and keyword conversion statistics.

An industry I like to pick on is the travel industry. In order to rank well for the solitary keyword "travel" in the search engines will require an astronomical SEO budget. But most people seeking travel information are looking for something just a bit more specific, like: Disney vacations, Hawaii vacations, and European travel.

So long as a keyword has been proven to convert visitors and sales, then it makes sense to optimize for that keyword. But you will never truly know which keywords will convert visitors and sales, until you have invested some of your budget into pay-per-click advertising and traffic analysis.

Once the necessary "keyword" knowledge is in hand, then the marketer can make an investment into search engine optimization for those keywords that can actually make them money, and with good SEO deployment, the marketer can find that they can actually capture a lot of the search engine traffic for specific keywords through the search engines' free listings.

Drupal Chimp

a layout tool in InDesign that allows for semi-automatic page layouts. Chimp has little to do with Drupal per se, but it has a lot to do with making print media more accessible for low-budget organisations and newsrooms. The beta we're running locally has cut about a third off our layout time, and we're aiming at chopping a full half of our time spent layouting. It's different from PrintCasting in that it's intended for small newsrooms (locals, student newspapers, ...) that have a layout-staff and want to be more productive, rather than providing a fully-automatic solution for people who can't afford designers. It's different from other automatic layout systems (like DTI PageMagic, the ISI docuboxx, ...) in that it'll be free rather than unaffordable for us mere mortals.

InDesign Integration Kit

The InDesign Integration Kit provides an interface for Chimp: a way to enter the layout parameters Chimp needs and a way to automatically export XML files of your articles and images that InDesign/Chimp can use. It also provides some InDesign scripts that can communicate layout previews and information about overset text to Drupal, thereby providing some two-way interaction between Drupal and InD.

Web Development - Round Corner Script

/* set millions of background images */
.rbroundbox {
background: url(nt.gif) repeat;
}
.rbtop div {
background: url(tl.gif) no-repeat top left;
}
.rbtop {
background: url(tr.gif) no-repeat top right;
}
.rbbot div {
background: url(bl.gif) no-repeat bottom left;
}
.rbbot {
background: url(br.gif) no-repeat bottom right;
}

/* height and width stuff, width not really nessisary. */
.rbtop div, .rbtop, .rbbot div, .rbbot {
width: 100%;
height: 7px;
font-size: 1px;
}
.rbcontent { margin: 0 7px; }
.rbroundbox { width: 50%; margin: 1em auto; }