Showing posts with label drupal interview questions. Show all posts
Showing posts with label drupal interview questions. Show all posts

Friday, April 25, 2014

97. Programming best practices and CMS(drupal) best practices

Programming best practices

 

Best practices (drupal)


Tuesday, April 22, 2014

86. Explain hardcoding in drupal ?

The temptation to hardcode happens to the best of us - that's why even the best of us are at risk of being burned by it.


Hardcoding defined

Hardcoding is the practice of making code tailored to handle very specific cases. Here are some examples of hardcoding as applies to Drupal:
·         Inserting an SQL query into a .tpl file
·         Writing a script that queries the database to make some changes to nodes
·         Using a regular expression on the output of a theming function to change one HTML class into another
The above examples might work some or even all of the time. However, like hacking core, efficacy alone is not sufficient to make them compatible with the "Drupal Way". Even when hardcoding works - and it often doesn't work as expected - it comes at the cost of that code's ability to handle a more general set of situations.

Why you should avoid hardcoding

Nobody would hardcode their Drupal site if it seemed like a bad idea to them. However, there are a large number of posted fixes on Drupal.org that rely on hardcoding in some way. That's because hardcoding is often attractive to coders who are in a hurry or are just learning. They see a way to save a lot of time, and in the short run, they're right. The problem is that there are hidden costs to hardcoding that can cost a lot of time.
Comments like "don't put code into the theming layer" or "use the hook system" are common, and represent prescriptive warnings against hardcoding. However, it can be hard for new Drupallers to find descriptive information about why hardcoding is usually a bad idea.
So, here are some specific examples where practicing hardcoding might cause problems down the road:

·         You're developing a theme.

You added a custom SQL query to retrieve and display information about the number of saved items a user has. Now you want to use that theme on a different Drupal install. What if the other install has a different set of table names, or is using a different module to store user information that requires a different sequence of joins? Your custom query is now useless.

·         You design a hand-crafted function to retrieve and display user information.

This ends up being very processor intensive, and your client wants to cache their results. What happens if you didn't originally anticipate the need to work with existing Drupal caching mechanisms?

·         You need to change the site theme based on what banner ad shows up on the site.

However, your code to choose a random banner ad is placed in the site's page.tpl file. This means that you won't know what banner ad is going to be shown until the page has already rendered to the point your function is called. What if the HTML before that needs to change?

·         You have five variants on your site's theme, using different template files.

Each of them has a hand-coded query you developed. If that query needs to change, you now need to make the same edit in six places - oops, did I say five? I must've forgotten that the site's mobile theme is in a totally different folder. You won't forget something like that, right?

·         Someone else starts working with your code.

If you used a hardcoded solution, do they have any idea what is going on, even if they're experienced in Drupal? Remember, if this is anything other than your personal blog, someone else may become involved with the project. Even if it is just your blog, how do you know how much you'll remember about your code a year from now?
Remember, the primary way that hardcoding fails is by failure to anticipate factors. To go from a page request to a served Drupal page requires that your server execute hundreds of functions. By using existing Drupal hooks, you're existing within the normal, expected flow of those operations. Do you thoroughly understand all the ways in which those functions interact? If not, your choice to operate outside the Drupal framework poses some uncertain amount of risk to your site/yourself/your pets.

Exceptions

Despite all of the above, though, hardcoding is different from hacking core in one crucial way: there are many legitimate uses for it and most Drupal developers will have to do it from time to time. Sometimes, you know that you'll only ever need to pick out a handful of cases and it is an efficient way to do that. An example might be displaying a Halloween theme on a specific node ID that you'll only use once a year. Using a module to add a form option to choose a theme would be undesirable if you knew you'd almost never use it.

If you are going to hardcode, exercise caution, and always ask for advice if you're uncertain about whether to do it at all. Or if you're certain, because that's even more dangerous.

Saturday, December 10, 2011

49. Compare Joomla and Drupal Terminology

  1. Joomla Template is called Theme in Drupal.
  2. Component = Module.
  3. Module = Block.
  4. Mambot/Plugin = Input filter.
  5. Menu-Horizontal = Primary Links
  6. Menu-Vertical = Navigation
  7. Dynamic Content Item = Story
  8. Static Content = Page
  9. Back-end = there is no back-end in Drupal,
  10. SEF = Clean URLs (but some docs refer to SEF, too).
  11. Section = Taxonomy Vocabulary/Term
  12. Section Title = Taxonomy Term (master)
  13. Category = Taxonomy Term (child)
  14. Introtext = Teaser
  15. Maintext = Body (see explanation below)
  16. Pathway = Breadcrumb

Other terms are the same, such as: forum discussion, editor, search, region, comment, subject/title, preview, html tag, view, edit, advertising/banner, log in/log out, profile, avatar, access control, logs, cache, site maintenance, RSS feed, parent-child and snippets.

46. How to Install Themes in your drupal website

  1. Download the theme.
    You can download drupal themes from http://drupal.org/project/themes, as well as some external sites like http://topdrupalthemes.net/, http://drupalthemesdownload.com/ , http://drupal2u.com/ , http://www.sooperthemes.com/drupal-themes , http://www.rockettheme.com/drupal-themes , http://fusiondrupalthemes.com/. Make sure the version of the theme matches your version of Drupal. Note that themes labeled "DEV" are in a development stage. They may be written for a previous/current/future version of Drupal, and they are considered unstable and should be handled with care.
  2. Extract the files.
    When you first get the theme, it will appear in a compressed file format such as 'tar.gz'. On Windows, use a program like 7-Zip to extract it. On the Mac, you can use Stuffit Expander. To extract the file using the Unix command line:
    tar -zxvf themename-drupalversionnumber.tar.gz
    You should see a list of files extracted into a folder.
  3. Upload the folder.
    FTP/Copy/SCP your files to the desired themes folder in your Drupal installation. Since the themes folder at the top level of Drupal is typically reserved for Drupal core themes, you should create a sites/all/themes/ directory and put uploaded themes there. If you are running a multi-site installation of Drupal, you can create a themes folder under sites/my.site.folder and put themes there that are specific to a particular site in your installation. Themes that will be shared between all sites should be placed in sites/all/themes.
  4. Read the directions.
    If the theme has an installation file (usually INSTALL.txt and/or README.txt), read it for specific instructions. There are themes that require special treatment to function properly.
  5. Enable the theme.
    Go to administer > site building > themes. Check the 'Enabled' box next to the theme.
  6. Optional: Make it the active, default theme.
    Check the 'default' box to make this the chosen theme for your site. Enabled alone will allow users to select the theme, if you have allowed that permission.
  7. Click the 'Save Configuration' button at the bottom.

If you run into problems, check the themes issue queue and search the forums. If your problem hasn't already been addressed, post a question and someone will try to help you out.

Friday, February 19, 2010

37. 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.

36. Is it possible to disable the core required modules through drupal admin ?

No, it is not possible to disable the core required modules.

35. Which are the core required modules in drupal 6.x ?

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

Tuesday, February 16, 2010

30. Explain the capabilities of views module.

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. It has four modes, plus a special mode, and provides an impressive amount of functionality from these modes.
Among other things, Views can be used to generate reports, create summaries, and display collections of images and other content.

Saturday, February 6, 2010

14. Explain User, Permission, Role in drupal.

Every visitor to your site, whether they have an account and log in or visit the site anonymously, is considered a user to Drupal. Each user has a numeric user ID, and non-anonymous users also have a user name and an email address. Other information can also be associated with users by modules; for instance, if you use the core Profile module, you can define user profile fields to be associated with each user.
Anonymous users have a user ID of zero (0). The user with user ID one (1), which is the user account you create when you install Drupal, is special: that user has permission to do absolutely eveything on the site.
Other users on your site can be assigned permissions via roles. To do this, you first need to create a role, which you might call "Content editor" or "Member". Next, you will assign permissions to that role, to tell Drupal what that role can and can't do on the site. Finally, you will grant certain users on your site your new role, which will mean that when those users are logged in, Drupal will let them do the actions you gave that role permission to do.
You can also assign permissions for the special built-in roles of "anonymous user" (a user who is not logged in) and "authenticated user" (a user who is logged in, with no special role assignments). Drupal permissions are quite flexible -- you are allowed to assign permission for any task to any role, depending on the needs of your site.


Video Answer
http://drupal-videos.blogspot.com/2014/06/drupal-video-user-permission-role-usermanagement.html

Thursday, February 4, 2010

4. What is Drupal ?

Drupal is an open-source platform and content management system for building dynamic web sites offering a broad range of features and services including user administration, publishing workflow, discussion capabilities, news aggregation, metadata functionalities using controlled vocabularies and XML publishing for content sharing purposes. Equipped with a powerful blend of features and configurability, Drupal can support a diverse range of web projects ranging from personal weblogs to large community-driven sites.

Video Answer
http://drupal-videos.blogspot.com/2014/06/4-what-is-drupal.html