Graham's Blog

Categories:

Import Excel/CSV into MySQL

To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV file.

You can then import it into a MySQL table by running:

Echo a view's block in a template file

<?php
	$block = module_invoke('views', 'block', 'view', 'Feaured_Content_Block-block_1');
	print $block['content'];
?>

Or

<?php
	print views_embed_view('home_page_rotor');
?>

md5 of "password"

password

5f4dcc3b5aa765d61d8327deb882cf99

Make Ubercart's Catalog sort by NodeOrder module's term weight

Modify: uc_catalog.module

NOTE! This was done in Drupal 5.x, be sure you know what you're doing! :)

  if (empty($_REQUEST['order'])) {
    $order = 'p.ordering, n.title, n.nid';
  }

to

  if (empty($_REQUEST['order'])) {
    $order = 'tn.weight_in_tid, p.ordering, n.title, n.nid';
  }

Fixing fckeditor for Drupal

  • Disable PHP Safe Mode
  • Modify sites/all/modules/fckeditor/fckeditor/editor/filemanager/connector/php/config.php with below code

require_once "../../../../../filemanager.config.php";

 

Echo a block's content in a template file

<?php
     $block = module_invoke('block' ,'block', 'view', 18);
     print $block['content'];
?>

Extract tar.gz files in a folder then delete them

find . -name '*.tar.gz' -exec tar -zxf {} \;
rm *.tar.gz;

Reset all your files and directories back to the server defaults of 755 and 644

The following commands reset all your files and directories back to the server defaults of 755 and 644.

    find . -type f -exec chmod 644 {} \;
    find . -type d -exec chmod 755 {} \;

Create symbolic link

ln -s {target-filename} {symbolic-filename}