كيف تجيد فن التركيز في زمن المشتتات؟! جـ2

GeekyMind

التدوينة السابقة كانت الجزء الأول عن هذا الموضوع، وبها نصائح جيدة لتساعد على التركيز والإنتاج، بعض الأحيان ستجد أن كثير من المشاكل لا تحتاج فقط بعض النصائح لحلها، خاصة وإن كانت مثل هذه المشكلة التشتت، لأنها من الأشياء الصعبة التيلا يمكنالتخلص منها بمجرد تطبيق بعض النصائح، إن كانت التدوينة السابقة مفيدة وأشارت لبعض المفاهيم والأشياء المهمة للتخلص من التشتت والحصول على تركيز أفضل، ففيهذه التدوينة ستتعرف كيف تتخلص من التشتت والتركيز بشكل جيد لكن بمنظور آخر.

القليل المبارك ولماذا الآن؟!

الكل الآن يسعى للمزيد، المزيد من المال، المنازل الكبيرة الفارهة، الكثير من الملابس والماركات العالمية، والاستهلاك الذي لا ينتهى، النّهَم الذي لا نشعر به، الأمر لا يتوقف هنا، بل كذلك للمقالات والصحف والشبكات الاجتماعية، تريد أن تقرأ كل مقال وكل تعليق، تريد أن تواكب المزيد والمزيد من المواد الجيدة للقراءة والمعرفة، ليس عيب، ولكن هل استفدت؟!

View original post 963 more words

Remove fieldset on a date field Drupal 7

For some reason you want to display the date field without the fieldset wrapper, it’s not difficult but it may take you time to notice that the theme function called is in the date.theme file (date module) :

/**
 * Returns HTML for a start/end date combination on form.
 */
function theme_date_combo($variables) {
  $element = $variables['element'];
  $field = field_info_field($element['#field_name']);
  $instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
 
  // Group start/end items together in fieldset.
  $fieldset = array(
    '#title' => t($element['#title']) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
    '#value' => '',
    '#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '',
    '#attributes' => array(),
    '#children' => $element['#children'],
  );
  return theme('fieldset', array('element' => $fieldset));
}

So to override the funtion and change the render of the field put this code in the template.php file of your theme :

/**
 * Render date field without fieldset
 */
function MYTHEME_date_combo($variables) {
  return theme('form_element', $variables);
}

Nice coding!

Show drupal status messages in omega theme region

I had to include the render of the drupal status messages ($messages) in the “region–content.tpl.php” template.

$messages is not available in regions (its a page variable, not a region variable). For Omega it is also a zone variable,

by default it is available in “zone–content.tpl.php”, to make it available for regions i had to add $messages via hook_region_process :

/**
 * Implements hook_process_region().
 */
function mytheme_process_region(&$vars) {
  $theme = alpha_get_theme();
  if ($vars['elements']['#region'] == 'content') {
    $vars['messages'] = $theme->page['messages'];
  }  
}

Than create a “region–content.tpl.php” which will contain :

<div<?php print $attributes; ?>>
  <div<?php print $content_attributes; ?>>
    <?php if ($messages): ?>
      <div id="messages" class=""><?php print $messages; ?></div>
    <?php endif; ?>
    <a id="main-content"></a>
    <?php print render($title_prefix); ?>
    <?php if ($title): ?>
    <?php if ($title_hidden): ?><div class="element-invisible"><?php endif; ?>
    <h1 class="title" id="page-title"><?php print $title; ?></h1>
    <?php if ($title_hidden): ?></div><?php endif; ?>
    <?php endif; ?>
    <?php print render($title_suffix); ?>
    <?php if ($tabs && !empty($tabs['#primary'])): ?><div class="tabs clearfix"><?php print render($tabs); ?></div><?php endif; ?>
    <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
    <?php print $content; ?>
    <?php if ($feed_icons): ?><div class="feed-icon clearfix"><?php print $feed_icons; ?></div><?php endif; ?>
  </div>
</div>

Hope this will be useful!

Troubles after importing a magento project from svn or git

I have been working on a magento project last few days and i have faced some troubles (I’m new to magento world) to run the magento store after importing from svn repository, here are some tricks I have found to make it work :
– Obviously import all directory structure from svn (or git), import the database and create your virtualhost
– Go to core_config_data table and change the “value” attribute to “your_local_virtualhost” where the “path” is “web/unsecure/base_url” and “web/secure/base_url”.
– Create the “app/etc/local.xml” file which will contains your database connection config, here is an example : local.xml
– Be sure that the “app/etc/config.xml” file exists, if not create it (you can copy one from standard magento installation directory)
– Be sure that the “.htaccess” file exists (base directory), if not create one by copying “.htaccess.sample” and renaming to “.htaccess”.

In case you forgot the admin login or password :
http://www.magentocommerce.com/wiki/recover/resetting-admin-password

Have a nice day !

Add custom table to Views in Drupal 6

While trying to fix an issue with google geocoding, I wanted to use a separate table for a list of “annonces” (content type) and then wanted to display the content of that table with views module.

By default views don’t display a custom table content but it provides a hook to do this – hook_views_data().

I have included this hook in mymodulename.views.inc file, which I created in a subdirectory named ‘includes’ of my module directory.

Here is the code in mymodulename.views.inc file :

function mymodulename_views_data() {
  // The 'group' index will be used as a prefix in the UI for any of this
  // table's fields, sort criteria, etc.
  $data['example_table_name']['table']['group'] = t('Import annonces');
  // Define this as a base table. 
  $data['example_table_name']['table']['base'] = array(
    'field' => 'annonce_id',
    'title' => t('example_table_name table'),
    'help' => t("Table contains imported annonces"),
    'weight' => -10,
  );
  // This table creates an 'implicit' relationship to the node table, so that when 'Node'
  // is the base table, the fields are automatically available 
  $data['example_table_name']['table']['join'] = array(
    'node' => array(
      'annonce_id' => 'nid',
      'field' => 'nid',
     ),
  );
  // Now, explain all the fields in this table. For
  // each field, you can define what field, sort, argument, and/or filter
  // handlers it supports. This will determine where in the Views interface you
  // may use the field.
  // Node ID field.
  $data['example_table_name']['nid'] = array(
    'title' => t('Node content'),
    'relationship' => array(
      'base' => 'node',
      'field' => 'nid',
      'handler' => 'views_handler_relationship',
      'label' => t('Node id in this table that references a node.'),
    ),
  );
  // Explain numeric fields in the table
  $data['example_table_name']['annonce_id'] = array(
    'title' => t('Id annonce'),
    'help' => t('annonce id'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['example_table_name']['filename'] = array(
    'title' => t('File name'),
    'help' => t('File imported'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['example_table_name']['files_count'] = array(
    'title' => t('Files count'),
    'help' => t('Count of imported files'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  return $data;
}

and then added this code to mymodule.module to get views to know this new table:

/**
 * Implementation of hook_views_api().
 * 
 */
function mymodulename_views_api() {
	return array(
			'api'  => 2.0,
			'path' => drupal_get_path('module', 'mymodulename') . '/includes',
	);
}

Hope this will be helpful!

Warning (512): Cache not configured properly. Please check Cache::config(); in APP/config/core.php [CORE\cake\libs\configure.php…

After importing a cakephp project from svn to work on,

I have got this error, the reason was that the “app/tmp” folder was not included in svn files,

So the solution was :

  • Create “app/tmp” folder and his sub folders (cache and logs)
  • Make them writeable (chmod -R 777 tmp on ubuntu in my case) 

 

Export/Import mysql database

this post is about expoting/importing mysql databases:

Export database:

mysqldump -h host -u username -p database_name > export.sql

where “export.sql” is the file that will contain database to export

Import databse :

mysql -h host -u username -p database_name < import.sql

where “import.sql” is the file containing database to import