Showing posts with label Interview Questions and Answers in Drupal. Show all posts
Showing posts with label Interview Questions and Answers in Drupal. Show all posts

Friday, September 23, 2011

Basic Inteview Questions in Drupal

1. What the steps to install Drupal Framework?
2. What are the Core Modules in Drupal and its uses?
3. What are the Optional Modules in Drupal and its uses?
4. What are the default Themes in Drupal?
5. What is the Purpose of .info file in Drupal?
6. How can we create a new Block in Drupal?
7. How can we create a new Menus in Drupal?
8. How can we change a separate theme for Admin and Front End theme?
9. What the the different types of files needed to Create a new Module in Drupal?
10. What is Cron?
11. What is Hook?
12. What is Region?
13. How can we add a new modules or themes into our application without disturbing the existing Drupal Structure?
14. How can we perform Multi-site in Drupal?
15. Where is the Setting / Configuration file in Drupal?
16. If we upload a image file in Drupal, by default where it will store?
17. What are the various purpose of .info file in Drupal?
18. What is the purposes and difference of page-front.tpl.php and page.tpl.php in Drupal?
19. What is Bootstrap in Drupal?
20. How can we perform URL Alias using Drupal?
21. What is Node?
22. How can we add a PHP Code while creating a Node in Drupal? What module needed for this?
23. What is the module needed to Upload a file in Drupal?
24. What is Taxonomy and its purpose?
25. What is the System Requirement (PHP, MySQL, Apache, System memory space etc..) needed to Install Drupal in our System?

26. What is the uses of Drupal and its latest version?
27. How can we add a new Javascript or CSS in our application using Drupal?
28. What is the Purpose of Backup Migrate Module in Drupal?
29. What is CCK and its nature of use in Drupal?
30. What is Views? and its purpose?
31. What is PDO?
32. What is Devel Module in Drupal?
33. What is Clear Cache in Drupal?

Basic Inteview Questions in Drupal

1. What the steps to install Drupal Framework?
2. What are the Core Modules in Drupal and its uses?
3. What are the Optional Modules in Drupal and its uses?
4. What are the default Themes in Drupal?
5. What is the Purpose of .info file in Drupal?
6. How can we create a new Block in Drupal?
7. How can we create a new Menus in Drupal?
8. How can we change a separate theme for Admin and Front End theme?
9. What the the different types of files needed to Create a new Module in Drupal?
10. What is Cron?
11. What is Hook?
12. What is Region?
13. How can we add a new modules or themes into our application without disturbing the existing Drupal Structure?
14. How can we perform Multi-site in Drupal?
15. Where is the Setting / Configuration file in Drupal?
16. If we upload a image file in Drupal, by default where it will store?
17. What are the various purpose of .info file in Drupal?
18. What is the purposes and difference of page-front.tpl.php and page.tpl.php in Drupal?
19. What is Bootstrap in Drupal?
20. How can we perform URL Alias using Drupal?
21. What is Node?
22. How can we add a PHP Code while creating a Node in Drupal? What module needed for this?
23. What is the module needed to Upload a file in Drupal?
24. What is Taxonomy and its purpose?
25. What is the System Requirement (PHP, MySQL, Apache, System memory space etc..) needed to Install Drupal in our System?

26. What is the uses of Drupal and its latest version?
27. How can we add a new Javascript or CSS in our application using Drupal?
28. What is the Purpose of Backup Migrate Module in Drupal?
29. What is CCK and its nature of use in Drupal?
30. What is Views? and its purpose?
31. What is PDO?
32. What is Devel Module in Drupal?
33. What is Clear Cache in Drupal?

Tuesday, August 9, 2011

How can a module depend on another module in drupal

; $Id: forum.info,v 1.6 2007/06/08 05:50:54 dries Exp $
name = Forum
description = Enables threaded discussions about general topics.
dependencies[] = taxonomy
dependencies[] = comment
package = Core – optional
core = 6.x
Using the dependencies in .info file, we can achieve this.

Which are the core optional modules in drupal 6.x ?

1. Aggregator Aggregates syndicated content (RSS, RDF, and Atom feeds).
2. Blog Enables keeping easily and regularly updated user web pages or blogs.
3. Blog API Allows users to post content using applications that support XML-RPC blog APIs.
4. Book Allows users to structure site pages in a hierarchy or outline.
5. Color Allows the user to change the color scheme of certain themes.
6. Comment Allows users to comment on and discuss published content.
7. Contact Enables the use of both personal and site-wide contact forms.
8. Content translation Allows content to be translated into different languages.
9. Database logging Logs and records system events to the database.
10. Forum Enables threaded discussions about general topics.
11. Help Manages the display of online help.
12. Locale Adds language handling functionality and enables the translation of the user interface to languages other than English.
13. Menu Allows administrators to customize the site navigation menu.
14. OpenID Allows users to log into your site using OpenID.
15. Path Allows users to rename URLs.
16. PHP filter Allows embedded PHP code/snippets to be evaluated.
17. Ping Alerts other sites when your site has been updated.
18. Poll Allows your site to capture votes on different topics in the form of multiple choice questions.
19. Profile Supports configurable user profiles.
20. Search Enables site-wide keyword searching.
21. Statistics Logs access statistics for your site.
22. Syslog Logs and records system events to syslog.
23. Taxonomy Enables the categorization of content.
24. Throttle Handles the auto-throttling mechanism, to control site congestion.
25. Tracker Enables tracking of recent posts for users.
26. Trigger Enables actions to be fired on certain system events, such as when new content is created.
27. Update status Checks the status of available updates for Drupal and your installed modules and themes.
28. Upload Allows users to upload and attach files to content.

What are systems requirements for drupal installation ?

System: 
- 3MB of disk space
- If you install many contributed modules and contributed themes, the actual disk space for your installation could easily be 40 MB or more (exclusive of database content, media, backups and other files).
Web Server
Drupal has been deployed successfully on both Apache and IIS.
Drupal is being developed to be web server independent, but we have limited or no reports of successful use on web servers not listed here.
Database server:
Recommended: MySQL 4.1 or MySQL 5.0
PostgreSQL 7.4 or higher
 
PHP:
Recommended: PHP 5.2.x
Required: PHP version 4.3.5 or higher (Contributed modules may not support this version of PHP)

List the features of Drupal ?

1. Rock solid & high quality platform
2. Powerful templating system. Any XHTML or CSS template can be easily converted to Drupal
3. Real multi-site-feature (only one installation for several sites)
4. Any Kind of user groups & user permissions, OpenId compliant in Version 6
5. Can run membership and community sites, not only CMS etc
6. Clear, high quality code and API (easy to integrate with other solutions etc)

How To Define New Regions in Drupal

To add regions for Drupal 5.xADD this code in its entirety to the bottom of your template.php file:

/** Define the regions **/
function framework_regions() {
    return array(
    ‘left’ => t(‘left sidebar’),
    ‘right’ => t(‘right sidebar’),
    ‘content’ => t(‘content’),
    ‘header’ => t(‘header’),
    ‘footer’ => t(‘footer’),
    ‘newregion’ => t(‘new region’),
    );
}
 
To add regions for Drupal 6.x
ADD the following code to you themename.info file:

    regions[left] = Left sidebar
    regions[right] = Right sidebar
    regions[content] = Content
    regions[header] = Header
    regions[footer] = Footer
    regions[newregion] = New Region
 

Database abstraction layer in Drupal ?

Allow the use of different database servers using the same code base.
Drupal provides a slim database abstraction layer to provide developers with the ability
to support multiple database servers easily. The intent of this layer is to preserve the
syntax and power of SQL as much as possible, while letting Drupal control the pieces of
queries that need to be written differently for different servers and provide basic security checks.
Most Drupal database queries are performed by a call to db_query() or db_query_range().
Module authors should also consider using pager_query() for queries that return results that
need to be presented on multiple pages, and tablesort_sql() for generating appropriate
queries for sortable tables.

What are hooks in Drupal ?

Allow modules to interact with the Drupal core.
Drupal’s module system is based on the concept of “hooks”. A hook is a PHP 
function that is named foo_bar(), where “foo” is the name of the module 
(whose filename is thus foo.module) and “bar” is the name of the hook. 
Each hook has a defined set of parameters and a specified result type.
 
To extend Drupal, a module need simply implement a hook. When Drupal wishes 
to allow intervention from modules, it determines which modules implement a hook and calls that hook in all 
enabled modules that implement it.

Can I use Drupal on the command line?

Yes, you can use drush –
drush is a command line shell and Unix scripting interface for Drupal

Monday, August 8, 2011

Core Required Modules in Drupal

Block    - Controls the boxes that are displayed around the main content.
Filter    - Handles the filtering of content in preparation for display.
Node    - Allows content to be submitted to the site and displayed on pages.
System    - Handles general site configuration for administrators.
User    - Manages the user registration and login system.

How do you handle upgrades?

It's a fact of life that you'll have to upgrade your Drupal installation 
and contributed modules fairly frequently. 

    * backing up the site,
    * putting it into maintenance mode
    * downloading the new version of the module
    * uncompressing it
    * running update.php
    * testing the site
    * taking the site out of maintenance mode

Views in Drupal

Views is a practical necessity for sites built on Drupal 6, and it's imperative 
that your developer understands how to take advantage of it. 
Earl Miles has written a great summary on the Views project page.

What is Views

The Views module provides a flexible method for Drupal site designers to control how lists and tables of content (nodes in Views 1, almost anything in Views 2) are presented. Traditionally, Drupal has hard-coded most of this, particularly in how taxonomy and tracker lists are formatted.

This tool is essentially a smart query builder that, given enough information, can build the proper query, execute it, and display the results.

Among other things, Views can be used to generate reports, create summaries, and display collections of images and other content.

You need Views if

  • You like the default front page view, but you find you want to sort it differently.
  • You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
  • You use /tracker, but you want to restrict it to posts of a certain type.
  • You like the idea of the 'article' module, but it doesn't display articles the way you like.
  • You want a way to display a block with the 5 most recent posts of some particular type.
  • You want to provide 'unread forum posts'.
  • You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.

PDO vs Drupal

PDO

PDO is an acronym for PHP Data Objects. PDO is a lean, consistent way to access databases. This means developers can write portable code much easier. PDO is a more like a data access layer which uses a unified API (Application Programming Interface).

How to enable PDO

To enable PDO, configure --enable-pdo and --with-pdo-sqlite --with-pdo-mysql or whatever database needs supporting by PDO (see the PHP manual for more information).

Windows users

  • For Apache, you will need to make sure php_pdo.dll and php_pdo_mysql.dll exist in the php/ext directory, un-comment or add the appropriate lines in php.ini, and restart the web server.
  • For IIS, PDO DLLs are not enabled by default. The preferred method for enabling them is to go to the Control Panel | Add/Remove Programs, highlight your PHP installation and click "Change" (Change/Remove - XP). Specify "FastCGI", then modify the installed extensions to include these two, then restart your server.

Devel Module in Drupal

A suite of modules containing fun for module developers and themers ...

Devel

  • Helper functions for Drupal developers and inquisitive admins. This module can print a summary of all database queries for each page request at the bottom of each page. The summary includes how many times each query was executed on a page (shouldn't run same query multiple times), and how long each query took (short is good - use cache for complex queries).
  • Also a dprint_r($array) function is provided, which pretty prints arrays. Useful during development. Similarly, a ddebug_backtrace() is offerred.

Installation

  • Download and install the latest version of the Devel module from Drupal.org.
  • Go to AdministerBuildModules and enable the Devel module.

How Cache works in Drupal

Caching process is done with the help of cache.inc file

cache_clear_all [ cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) ]
Expire data from the cache. If called without arguments, expirable entries will be cleared from the cache_page and cache_block tables.

cache_get
[cache_get($key, $table = 'cache') ]
Return data from the persistent cache. Data may be stored as either plain text or as serialized data. cache_get will automatically return unserialized objects and arrays.

cache_set
[cache_set]
Store data in the persistent cache.





Different Cache related table in Drupal

  • Structure cache
  • Structure cache_block
  • Structure cache_content
  • Structure cache_filter
  • Structure cache_form
  • Structure cache_hierarchical_select
  • Structure cache_menu
  • Structure cache_page
  • Structure cache_update

Tuesday, July 12, 2011

Interview Questions & Answers in Drupal

  1. Whether drupal is written in procedural-style or object oriented? (Procedural oriented)
  2. why not object oriented? ( when drupal is in initial stage, PHP is not full integrated with OOPS. Also absence of class and constructors. )
  3. Why Drupal? Advanced URL Control,Custom Content Types and Views,Revision Control,Taxonomy,User Management,Page Titles and Meta Tags,Excellent Documentation,PHP Template, Drupal Cookbooks, Large and Friendly Community
  4. How does drupal know when to invoke a module to handle the particular request? ( This is done by hook mechanism. Drupal check currently enabled modules and find the call back functions and then execute it ).
  5. how can we prevent to load all the modules while the page is render? (we can change the module_load_list function in module.inc. Here we can set the modules to load based on the page.)
  6. what are the three argument for hook_block? ($op,$delta,$edit)
  7. what are the possible values for $op?
    1. list :- This is passed when the module should provide information about itself.
    1. view :- This value is passed in $op when Drupal expects the block hook to
      provide content for displaying to the user.
    2. configure :- This value is passed when Drupal expects an administration
      form used to configure the block.
    3. save :- value is passed when configuration information from the form
      data generated by configure needs to be saved.
  1. $delta contains extra information about what content should be displayed.
  1. $edit parameter is used during configuration.
  2. what is the purpose of the t()?. This is translation function. Its is used to provide multi-language support. To do this, we need to enable the content translation module.
  3. what are the placeholders? !,@,%
  4. how do declare private function & purpose? leading underscore char in the function name tells that its private function. function _test(). its called by other function with in the module.
  5. How to you prevent the XSS (cross site scripting)? we can use check_plain(). It will encode the HTML tags into  entities. check_plain('<em>Example</em>') would return the
    string &lt;em&gt;Example&lt;/em&gt;.
  6. what is the disadvantage of check_plain? if encounter the HTML entity then it will encode again. Ex. &lt; would become &amp;lt;. The initial ampersand (&) is encoded into &amp;.
  7. what is derivative theme? Derivative theme is theme. its derive the CSS,images and JS from parent theme. To call the parent theme, we need to call them basetheme = themename in theme.info file.
  8. Advantage and disadvantage of derivative theme? It call the CSS,images and JS from parent theme except the info file of parent theme. it can override the behavior of parent. Disadvantage :- if CSS or images changed in parent it will reflect into derivative theme too.
  9. what is derivative theme of garland? minelli
  10. why we put our custom module in sites/all/ path? To keep the core and custom modules in different location. If we upgrade into new version, then custom modules won't affect.
  11. styles[all][]. what is mean by [all] :-  It [all] indicates that media type of pages the given style sheet should be used in. common media types are screen, print. so that, we are using styles[print][] in some case.
  12. All the engines are not having the template.tpl.php. but chameleon theme having the template.tpl.php without using any engines.
  13. Difference between theme and theme_function? theme() makes use of the full theme system. theme_hook function directly may cause your application to ignore
    the current theme configuration and use only the default. themes better than use theme_hook. (theme, check the function (phptemplate_image) or template (image.tpl.php) that overrides the theme_function, if function found then that used as.) theme_hook can overrides by templates like image.tpl.php
  14. The template.php file provides a convenient way to override the default theme behavior. It also provides access to data before the data is handed on to the template. Accessing such data before it is themed is called preprocessing.
  15. Template.php Gotchas:-
    1. you can only override a theme function once. While this seems simple, there is one circumstance in which this may be surprising. While you can declare a template.php file in a sub-theme even if there is a template.php in the parent, you cannot override functions declared in the parent. If the parent's template.php declares phptemplate_breadcrumb(), then the sub-theme's template.php cannot declare phptemplate_breadcrumb(). Doing so will result in a PHP errors for redeclaring a function.
    1. we have seen that theme hooks (theme_<hookname>()) (theme_block) can be overridden by PHPTemplate templates (block.tpl.php) and also by functions (phptemplate_block) in the template.php file. But what happens if you declare both?
      The phptemplate_<hookname>() function overrides the theme function that would otherwise load the template. Therefore, if phptemplate_block() is defined in template.php and there is a template named block.tpl.php, the phptemplate_block() function will be called to render all blocks, and the block.tpl.php file will never be used.
    2. If you need to manipulate some content before it is passed to a template, don't do this by defining phptemplate_<hookname>(). Instead, use one of the preprocessor
      functions, such as phptemplate_preprocess_block(), phptemplate_preprocess_node(), or phptemplate_preprocess_page().
  1. while we use drupal_goto and $form['#redirect'], drupal_goto overrides the $form[#redirect];
  1. Table name placeholders ({node}) provide administrators the ability to change table names to better fit existing conventions. For example, some ISPs require that all tables have certain pre-determined prefixes. By using table name placeholders, we can avoid the need to make changes to code when table names are changed in the database.
  2. what will happen if admin delete the user account suppose the user logged in the site? If user is in my account page, then its shows page not found. If user is in common page (ie, static page, access for all) then simply it will be in same page.
  3. what is the purpose of the table placeholders in query? Some ISPs require that table prefixes. In that case, we can simply give the prefix in settings.php and add the prefix to add all the tables. No need to change that in code of modules.
  4. Note that instead of hook_form_alter(), which is called for all forms, you can also use hook_form_FORM_ID_alter() to alter a specific form.
  5. how to delete module via application?
  6. what is the difference between l() & Url()? Both is used to format the link. l() handles the aliased paths, and allows themes to highlight links to the current page correctly. we can use l() than url();
  7. The data is divided between two tables: {menu_router} and {menu_links}. The {menu_router} table is built based on the callbacks defined by implementations of hook_menu, and Drupal now looks in this table to determine access and the appropriate callback function when a site visitor tries to navigate to a particular path. Everything belonging to one path is one row in a database table, so the memory footprint is significantly smaller. The inheritance rules for access, etc. are cleanly laid out in the documentation. The {menu_links} table contains the links that are displayed in the Navigation and other menu blocks. Some of these items are derived automatically from {menu_router}, but others may be added by the site administrator using the menu module or other modules. 
  8. When you open a page, then the system will generate the ancestors of the given path, and ask the database for the menu entry of the ancestor which best fits this path. Then it calls the access callback to determine access. If it's given, then it hands over execution to the page callback.
  9. What is ancestors:- node/12345/edit, node/12345/%, node/%/edit, node/%/%, node/12345, node/%, node. These we call the ancestors of node/12345/edit.
  10. What is fitness:-  So let's add fitness number to these paths:
  11. Path Fitness Fitness in binary
  12. node/12345/edit 7  111
  13. node/12345/% 6  110
  14. node/%/edit 5  101
  15. node/%/% 4  100
  16. node/12345 3   11
  17. node/% 2   10
  18. node 1    1
  19. What will happen if page call back is not defined?
  20. If a page callback is not defined for a path, then we look at the closest parent that has one and use it. If the page callback is inherited from a parent, then the page arguments, the file and the file path are inherited from the parent as a whole, but can be overridden. Most of the time it is only required to overwrite the page arguments and nothing else.
  21. What will happen if parent also not defined? It will display you are not authorized to access the page
  22. why only a title column exists for nodes in the node table and not a body?
  23. What will happen, if our page callback & core module page callback same? for example  if we have 'contact' as page callback when we enabled the core contact module. Ans:- Existing call pack will be overridden by Newly created page callback.
    Theming :-

  24. Theme name should start with an alphabetic character and contain no spaces or punctuation. Underscores are allowed but not hyphens.
  25. Warning! Modules bearing the same internal name as a theme can prevent a site from functioning. This may cause duplicate function names, which are illegal in PHP. All installed components must have unique names. For locally created themes using a prefix that is likely to be unique is good for theme naming. A site example.com might call its themes ex_themename.
  26. Define  Java scripts in .info :- scripts[] = validate.js (External javascript files can not be include)
  27. Engines in .info file:-  engine = phptemplate. it will discover the theme functions and templates for the behavior of themes.
  28. Regions names should contain alphanumeric characters and underscores.
  29. Assign the contents into regions manually by drupal_set_contents('region name' , 'output content'); 
  30. Making settings available to the administration page :-  In .info file, we can mention which is need to enable by features[] = logo
  31. Create new form filed in theme settings page :- we need to create the theme-settings.php in theme folder. http://drupal.org/node/177868

Followers