Web Development Information [PHP, DRUPAL, MYSQL, MAGENTO, JQUERY, JAVASCRIPT, CSS, HTML5]
Wednesday, September 28, 2011
Difference between MySQL DELETE and MySQL TRUNCATE
MySQL DB Engines.
States in Ajax
Destroy a session in PHP
XHTML Syntax Rules
Attribute names must be in lower case
Attribute values must be quoted
Attribute minimization is forbidden
The XHTML DTD defines mandatory elements
Inheritance in PHP
Tuesday, September 27, 2011
Advantages of InnoDB and MyISAM
How to create a copy of the database in MySQL in command line?
Hook functions in Drupal 6.
hook_auth->Verify authentication of a user.
hook_block->Declare a block or set of blocks.
hook_comment ->Act on comments.
hook_cron->Perform periodic actions.
hook_db_rewrite_sql ->Add JOIN and WHERE statements to queries and decide whether the primary_field shall be made DISTINCT. For node objects, primary field is always called nid. For taxonomy terms, it is tid and for vocabularies it is vid. For comments, it is cid. Primary...
hook_delete->Respond to node deletion.
hook_elements->Allows modules to declare their own form element types and specify their default values.
hook_exit->Perform cleanup tasks.
hook_file_download ->Allow file downloads.
hook_filter->Define content filters.
hook_filter_tips->Provide tips for using filters.
hook_footer->Insert closing HTML.
hook_form->Display a node editing form.
hook_form_alter->Perform alterations before a form is rendered. One popular use of this hook is to add form elements to the node form.
hook_help->Provide online user help.
hook_info->Declare authentication scheme information.
hook_init->Perform setup tasks.
hook_insert->Respond to node insertion.
hook_install->Install the current version of the database schema.
hook_link->Define internal Drupal links.
hook_load->Load node-type-specific information.
hook_menu->Define menu items and page callbacks.
hook_nodeapi ->Act on nodes defined by other modules.
hook_node_grants->Grant access to nodes.
hook_node_info->Define the human-readable name of a node type.
hook_perm->Define user permissions.
hook_ping->Ping another server.
hook_prepare ->This is a hook used by node modules. It is called after load but before the node is shown on the add/edit form.
hook_search->Define a custom search routine.
hook_search_preprocess->Preprocess text for the search index.
hook_settings->Declare administrative settings for a module.
hook_submit->This is a hook used by node modules. It is called after validation has succeeded and before insert/update. It is used to for actions which must happen only if the node is to be saved. Usually, $node is changed in some way and then the actual saving of...
hook_taxonomy->Act on taxonomy changes.
hook_update->Respond to node updating.
hook_update_index->Update Drupal's full-text index for this module.
hook_update_N->Perform a single update. For each patch which requires a database change add a new hook_update_N() which will be called by update.php.
hook_user->Act on user account actions.
hook_validate ->Verify a node editing form.
hook_view->Display a node.
hook_xmlrpc->Register XML-RPC callbacks.
module_hook->Determine whether a module implements a hook.
module_implements->Determine which modules are implementing a hook.
module_invoke->Invoke a hook in a particular module.
module_invoke_all->Invoke a hook in all enabled modules that implement it.
Default files in themes folder
1.info file
2.style.css
3.page.tpl.php
4.node.tpl.php
5.block.tpl.php
6.logo.png
7.screenshot.png
Is CSS case sensitive?
If your page having an XML declaration and an XHTML DOCTYPE then the CSS selectors will be case-sensitive for some browsers, if your page having a HTML DOCTYPE then your CSS selectors will be case-insensitive.
div.myclass { ...}
div.myClass { ... }
What is XHTML?
XHTML stands for EXtensible HyperText Markup Language
XHTML is almost identical to HTML 4.01
XHTML is a stricter and cleaner version of HTML
XHTML is HTML defined as an XML application
XHTML is a W3C Recommendation
Can i have two or more actions in the same form?
Template function in Drupal
function phptemplate_body_class($left_top, $left_bottom, $right) - Sets the body-tag class attribute.
function phptemplate_comment_wrapper($content, $node) - Allow themable wrapping of all comments.
function phptemplate_preprocess_page(&$vars) { - Override or insert PHPTemplate variables into the templates.
function phptemplate_breadcrumb($breadcrumb) {
function fastlivemail_menu_tree($tree) {
function fastlivemail_menu_item_link($link) {
function fastlivemail_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
function fastlivemail_button($element) {
function fastlivemail_tablesort_indicator($style) {
function phptemplate_get_ie_styles() { - Generates IE CSS links for LTR and RTL languages.
Monday, September 26, 2011
Drupal AHAH Delete button not working properly
1) Click on create content
2) Upload an image
3) and press Delete button
This causes the form to submit, instead of doing the ajax call, and the item is not deleted.
Seems that when you upload an image, the image_upload_js function rebuilds the form, and the ahah of the Delete button does not work.
You can check this because after uploading an image the class of the Delete button isclass="form-submit" instead of class="form-submit ahah-processed".
When the form is fully submitted, then the Delete button class is class="form-submit ahah-processed" and it works.
Maybe the del button ahah content doesn't work if it hasn't been initialized in the $(document).ready because it didn't exists in the .ready event.
Perhaps loading initially the button as "hidden" may be a solution ?
Ans:
Before sending the response to JSON...Add the following lines...
==========
// AHAH is not being nice to us and doesn't know the "other" button (that is,
// either "Upload" or "Delete") yet. Which in turn causes it not to attach
// AHAH behaviours after replacing the element. So we need to tell it first.
// Loop through the JS settings and find the settings needed for our buttons.
$javascript = drupal_add_js(NULL, NULL);
$filefield_ahah_settings = array();
if (isset($javascript['setting'])) {
foreach ($javascript['setting'] as $settings) {
if (isset($settings['ahah'])) {
foreach ($settings['ahah'] as $id => $ahah_settings) {
if (strpos($id, 'ahah-more') || strpos($id, 'ahah-remove')) {
$filefield_ahah_settings[$id] = $ahah_settings;
}
}
}
}
}
if (!empty($filefield_ahah_settings)) {
$output_settings = 'jQuery.extend(Drupal.settings.ahah, '. drupal_to_js($filefield_ahah_settings) .');';
}
File field and AHAH button not working together in dynamic form
For some reason, file uploads don't like drupal_json() with its manual setting of the text/javascript HTTP header. So use this one instead.
Solution:
==========
Instead of using
"drupal_json(array('status' => TRUE, 'data' => $output));"
need to use
" print drupal_to_js ( array ( 'status' => TRUE, 'data' => $output ) ); exit "
First uploaded picture not overwrite when resubmit the user picture
1. Upload a user picture
2. delete the picture
3. resubmit another picture.
Error: The first picture was not replaced.
delete all caching mechanisms (Website/browser) and retry.
Ans:
We can't change the core module(user.module). So we can change in hook_user. May be this will get error when we upgrade the version.
Another way to change the user picture.
Use hook_user function, in switch case, rename the file path with timestamp and update user table as same file path
Example:
function hook_user($op, &$edit, &$account, $category = NULL) {
switch($op){
case 'after_update':
case 'after_update':
$old_filename = $account->picture;
$filename = basename($account->picture);
$fileArray = explode('.', $filename);
$finalFilename = $fileArray[0].'-'.time().'.'.$fileArray[1];
$pictureArray = explode('/', $account->picture);
$pictureArray[count($pictureArray)-1]=$finalFilename;
$picturePath = implode('/', $pictureArray);
$account->picture = $picturePath;
rename($old_filename, $picturePath);
db_query("UPDATE users SET picture='$picturePath' WHERE uid=%d", $account->uid);
break;
}
}
This will work.
Safari CSS Hack code
Drupal 6 Schema
Create "module.install" file under the module.
Create the following hook function to add schema,
hook_schema()
hook_install()
hook_uninstall()
// Define a table
function hook_shema(){
// Define table array
For example:
$schema['node'] = array(
'fields' => array(
'nid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => t('Primary Key'),
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('Status.'),
),
),
'primary key' => array('nid'),
);
}
// Install all the tables while enable the module form list
function hook_install() {
drupal_install_schema(hook);
}
// Drop the all tables while uninstall the module
function hook_uninstall() {
drupal_uninstall_schema(hook);
}
// Add one row to table
drupal_write_record(table_name, $record_object);
// Update a row in a table
drupal_write_record(table_name, $record_object, primary_key);
Show CSS Light Box Alert When Disable Javascript
Drupal 6 Installation Profile
with minimum requirements.
Profile folder name: root/profiles/new-profile
Create the following files/folders under profiles folder(new-profile):
modules - folder
themes - folder
new-profile.profile - file
Inside this new-profile.profile file , you will write the following hook_profile_funcs().
• new-profile_profile_modules() - Core, Contributed and customized modules
to be enabled when this profile is installed
• new-profile_profile_details() - description of the profile for the
initial installation screen
• new-profile_profile_tasks() - list of tasks that this profile supports
(functions, initial database changes).
List of Modules in Drupal 6
Friday, September 23, 2011
How to configure php.ini file settings in PHP code?
List of possible variable can change using ini_set() function.
For example:
ini_set('max_execution_time', 120);