Mywebdunia's Blog

Archive for the ‘Drupal’ Category

Blocks are nothing but boxes of content, that are displayed in regions such as sidebar or footer on your page.

For creating a block go to Administer >> Block >> Add block, you will find a form fill the details of your block and save it.

Say for Example you have created a block with name Test Block with ID 1. Here’s how you use this code snippet to insert any block

Browse to Site Building >> Blocks >> List Browse over the “configure” link next to your block

This will reveal the following address line (in this example we are using a custom block with ID 1)

/admin/build/block/configure/block/1

the last two variables are the ones we’re interested in: /block/1

Now to place this custom block into a page, we need to just add these code into the PHP code snipped

<?php
$block = module_invoke(‘block‘, ‘block’, ‘view’, 1);
print $block[‘content’];
?>

Note that the middle two terms (‘block’, ‘view’) always stay the same. You’re simply updating the first and last term.

The first term can be a comment, user, event, block or module_name for displaying recent comments, online user, if you have event module installed you can show list of upcoming events or to display a custom block created by Administrator or any module to be displayed respectively.

And the last term “1” indicates the first block. To display 2nd , 3rd, and subsequent user created blocks replace 1, with, 2, 3 etc respectively.

Backing up your Drupal site is now very easy, just need to download and  install the Backup & Migrate Module. To install the module click on the Administer> Modules check the Backup and Migrate module and enable it and save the settings.

Then go to the Administer > Content Management > Backup and Migrate then make the following settings

1. Exclude the following tables altogether: select the table which you dont want to take backup .

2. Give the backup file name.

3. There are also options to compress the file before download, or add a datestamp.

And then click Backup Database.

Backup and Migrate is the easiest module that is available. The other method would be through  PhpMyAdmin.

Drupal is one of the best and Award winning CMS, and one of its best feature is taxonomy.

New users to Drupal can find it bit difficult to understand this feature at first, which even I found it to be difficult for me at first.

Taxonomies are nothing but which allows you classify content into categories and subcategories. Drupal taxonomy is made up of vocabularies and terms. A vocabulary is a set of terms and terms are just another word for categories.

To look more into the Taxonomy, first log into the administrative block of your site. Then click on the Administrative link on the left menu. Find for the taxonomy(which comes under ( Content Management ) link click on that.

Let’s build the taxonomy for a news site as an example. First click on the Add vocabulary tab. Fill all the details into the boxes that is the Vocabulary name, some description, types and hierarchy and save the settings.

The vocabulary has been created, but there are no terms categories in it yet. Click on the Add terms link. Enter the term name, description select the parent and then save the settings. Continue the same procedure for those many terms and vocabularies you need.

For Example this could be the structure:

News [this is the name of your vocabulary]

  • Business
    • Markets
    • Commodities
    • Mutual Funds
  • Cricket
    • Latest
    • Live Cricket
    • Technology

Whenever you develope any CMS based website, the important thing is to have search engine friendly URL’s. Because you might have seen some url’s like http://www.sitename.com/products/pid=23&id=2 such url’s are not search engine freindly most of the search engines doesn’t scan such things. So its better you make your url’s clean like http://www.sitename.com/products/x/y this makes search engine friendly.

To get this with Drupal there are some steps that need to be followed.

1. Assuming that you have alread installed Drupal, enable the Path module to enable this login into your administrative block. Once you are logged in click on Administrative link on the left menu and then click on the Modules link, scroll down the page and find the Path module check on the checkbox left of the module and save the settings.

2. The next step is to check for the clean URL’s  click on the Administrative link on the left menu and then click on Site Configuration and then click on the Clean URLs link  select the Enable radio button and save the settings.

Now go to the front end of your site and point the mouse over a link. In the status bar and in the address bar you will notice that all links will be in clean (human readable) format.

If you want  to reset your current Drupal installation password the following are the steps:

1. Go to your control panel or  PhpMyAdmin.

2. Select the database which Drupal use from the drop-down menu on the left.

3. Click on the SQL tab which is at the right top.

4. In the text field on the page type the following text:

update users set pass=md5(‘NEWPASS‘) where uid = 1;

where “NEWPASS” is your new administrative password. Then click on the GO button and if no errors present, the Drupal password should have been changed.

If you are building search-engine-friendly Web sites and want them to be scalable, you should be using a content management system rather than building sites with plain HTML pages or Dreamweaver templates.

Here are few reasons for why CMS(Content Management System) :

1. It generally stores all your content into database.

2. It keeps the site design seperate from your content.

3. Makes it so that to update something on every page of your CMS Web site you generally only have to update it in one place, not on every individual page of the Web site.

These all makes the CMS highly scalable and also allow non-technical users add and edit the content without needing to know any HTML or Web design knowledge.

 

Some example drupal sites that I have generated are:

Some other example of drupal  sites are:

Drupal is one of the strongest open source, the best CMS that I have seen so far. If you are intrested in developing search engine friendly  website with content management system then I suggest you should go for Drupal CMS. 

The following down below are some of the reasons for why drupal.

1. URL Control : Drupal gives you good control of urls. Each item of drupal content called node can be given a custom URL(called a URL alias). In WordPress you are generally limited to one type of permalink URL for all posts. You can also automate custom URL structures for each different content type with the Pathauto Module. The Global Redirect Module will automatically 301 redirect the internal Drupal URL to the custom URL alias. Unlike many other content management systems, Drupal’s content pages have nice clean URLs.

2. Revision Control :  You can configure Drupal to save a new version of your pages every time they are editing. That means that you can go back to view or revert old revisions if you want at any time.

3. Page Titles and Meta Tags :  Drupal’s Page Title Module gives you custom control of your HTML <title> elements, while the Meta Tags Module gives you control over your pages’ individual meta description tags. This is difficult to achieve with other content management systems, but it’s easy with Drupal.

4. Taxonomy :  Drupal has a powerful taxonomy (category) system that allows you to organize and tag content. Each Drupal “vocabulary” (set of categories) can be limited to certain content types. You can also have hierarchical categories, with single or multiple parent categories. Drupal’s advanced taxonomy features, combined with CCK and Views, allows you to easily target all of those long-tail keywords that you researched in Wordtracker. 

5.  User Management  :  Drupal was designed for community-based Web sites and has strong user role and access control functionality. You can create as many custom user roles with custom access levels as you need. For example you could create the following roles, each with different levels of access to your features: “anonymous visitor”, “authenticated user”, “moderator”, “editor”, “webmaster”, “admin”. You can keep the advanced user management features (like multiple blogs) turned off if you don’t want them, enabling them later if your site grows to a point where you would like to add more community features.

6. PHP Template :  Drupal uses the PHP Template theme engine by default. Theming in Drupal is easier than theming in WordPress and doesn’t necessarily require any PHP knowledge.

There are other open-source alternatives to Drupal, but here are a few reasons why I think that Drupal is better:

  • Joomla – It’s not as search engine friendly out of the box as Drupal.
  • Plone – It”s powerful, but Plone is written in Python and has certain server requirements. It is not as easy to extend as Drupal, and it’s harder to find people who know Python than who know PHP. Plone runs on the powerful, but complex, Zope 2.
  • WordPress – WordPress is excellent, but if you need something more heavy-duty or are building a site that you might want to extend in the future you should be considering Drupa

Here is a list of drupal template variables that we commonly use in phptemplate variable page.

1.  $breadcrumb :  HTML for displaying the breadcrumbs at the top of the page.

2. $closure :  Needs to be displayed at the bottom of the page, for any dynamic javascript that needs to be called once the page has already been displayed.

3. $content :  The HTML content generated by Drupal to be displayed.

4. $footer_message : The footer message as defined in the admin settings.

5. $head :  HTML as generated by drupal_get_html_head().

6. $head_title : The text to be displayed in the page title.

7. $title :   Title, different from head_title, as this is just the node title most of the time.

8. $logo :  The path to the logo image, as defined in theme configuration.

9. $mission :  The text of the site mission.

10. $primary_links :  An array containing the links as they have been defined in the phptemplate specific configuration block.

11. $secondary_links :  An array containing the links as they have been defined in the phptemplate specific configuration block.

12. $sidebar_left :  The HTML for the left sidebar.

13. $sidebar_right :  The HTML for the right sidebar.

14. $site :  The name of the site, always filled in.

15. $site_name :  The site name of the site, to be used in the header, empty when display has been disabled.

16. $site_slogan :  The slogan of the site, empty when display has been disabled.

17. $styles :  Required for stylesheet switching to work. This prints out the style tags required.

18. $tabs :  HTML for displaying tabs at the top of the page.

19. $scripts  :  HTML to load the JavaScript files and make the JS settings available. Previously, javascript files are hardcoded into the page.tpl.php.

20.  $base_path:   Returns the base URL path of the Drupal installation. At the very least, this will always default to /.

21. $help :  Dynamic help text, mostly for admin pages.

22. $language :  The language the site is being displayed in.

23. $is_front  :  True if the front page is currently being displayed. Used to toggle the mission.

24. $node :  (5.x and after only) If you are in page.tpl.php displaying a node in full page view then $node is available to your template.

25. $layout :  This setting allows you to style different types of layout (‘none’, ‘left’, ‘right’ or ‘both’) differently, depending on how many sidebars are enabled.

26. $search_box :   True(1) if the search box has been enabled.

If  you are not running your latest version of Drupal you need to upgrade it to the latest stable version. Here are some steps for upgrading your drupal version from 5.x to 6.x

1. Take backup of the sites and files directory.

2. Place your site in the Offline mode.

3. Switch your theme to the default Garland theme if you have changed it to your own customized theme.

4. Disable all Custom and Contributed module.

5. Remove all old files and directory of drupal installation.

6. Copy the new version of the files.

7. Copy the backed up sites and files directory.

8. Check for configuration files for correct information.

9. Run the update.php by visiting the site http://www.yourdomain.com/update.php

10. Re-Install the contributed module according to the drupal version(For module installation click here )

One you are done with Drupal core files installed,  you can start adding third party contributed modules the basic instructions are as follows.

1.  Download the Module : Download the module and make sure that it matches with your drupal version.

2. Extract Files and Upload through FTP: Extract the compressed file and upload the same files to the sites/all/modules directory.

3. Read the README.txt or INSTALL.txt:  Read the README.txt and/or INSTALL.txt for specific instructions. As some of the modules need some special treatment for the installation.

4. Enable the Module: Enable the module by navigating through Administer » Site Building » Modules. Click on the boxes next to the modules and the click  Save Configuration at the bottom.

5. Set File Permissions: Set file permissions if modules require change permissions or settings to get them working. For setting the permissions navigate through Administer » User Management » Permissions, look for the module and change the permissions.


Categories