This blog contains solutions to problems I encountered implementing drupal.

New drupal site Kosmospiraat.com using gigya module

A new site implementing gigya. The module has been altered in many ways.

Making it more usable.

For example the login flow is changed.
The original module didnt support a site with existing users. The flow was changed so the existing users get the chance to connect their account on the site by signing in for the last time. After users are connected, they log in using only their facebook account. For new users after choosing they are new, a drupal account is created using :

user_external_login_register($name, $module);

entertainment, facebook, gigya, social media

Solution : Curl webservice CURLE_SSL_CACERT (60) Peer certificate cannot be authenticated with known CA certificates.

I was trying to post to a webservice and was getting the 60 error code: Peer certificate cannot be authenticated with known CA certificates. .
The webservice I was trying to reach was over https.
The solution is very simple.
You need to set curl not to verify the ssl peer. You can do this by setting an option.

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

The complete code to do a curl request:

  $ch = curl_init();
 
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_POST,count($fields));
  curl_setopt($ch,CURLOPT_POSTFIELDS,$string);

curl, Php, webservice

Using twitterfeed to automatically post links when I update my blog

At http://twitterfeed.com you can create an account.
Fill in your twitter account.
Submit a feed to your blog.
And posts are posted to your twitter account periodicaly using your blogs feed.

feed, twitter

Drupal 6 importing taxonomy terms easy mode

I just discovered a very handy api to import taxonomy.
It is included with the taxonomy csv module in the file taxonomy_csv.api.inc

I needed to do something very simple import some terms into a vocabulary (no hierarchy, no related terms, just tags..). I already had my csv parser to create my nodes so I did not use the interface of the module. Since I had my terms in an array I just needed to prepare them and import them with this api function :

  //prepare
  $terms = array(
    array('name' => $data[20]),

drupal6, importing, taxonomy

Solution : Drupal Locale language files dont get rebuild

locale language files dont get rebuild and they keep generating page not found errors.
Here is a fix to rebuild the lost translation files.

a little module for D6 which
Provides locale admin pages with buttons to rebuild/invalidate js translations.

- enable the module
- navigate to admin/settings/language#js-translations
- expand "JavaScript translations" fieldset
- use either "Invalidate js translations" or "Rebuild js translations" buttons

http://drupal.org/files/issues/2009-09-12%20tweak_locale_js_0.zip

drupal6, locale

Solution to Transfer files by php ftp_put() : warning: ftp_put() [function.ftp-put]: Opening data connection

The whole thing did not work without this line.

ftp_pasv($conn_id, true);

Apparently with some ftp accounts you need to transfer in passive mode. As usual not documented by the client.

The full excerpt:

function exporter_vdab_ftp($file_path,$file_name) {
  // set up basic connection
  $file = $file_path . '/'.$file_name;
  $ftp_server = VDAB_FTP_SERVER;
  $conn_id = ftp_connect($ftp_server);
 
  // login with username and password
  $ftp_user_name = VDAB_FTP_USER;
  $ftp_user_pass = VDAB_FTP_PASS;

ftp, Php

Drupal alias your file paths using htaccess

Clients often ask for clean urls in file names because they want to publish them in magazines so they want urls as clean as possible. H

Here is how to do this using mod_rewrite rules in htaccess:

In your .htaccess file of your drupal root folder you add following line.
For example :
All http://yourdrupal/pdf/whatever.whatever will be redirected to http://yourdrupal/sites/yourdrupal/files/private/whatever.whatever

  RewriteRule ^pdf/(.*)$ /sites/yourdrupal/files/private/$1 [L,QSA]

alias, drupal, files, htaccess

MAC OS Xampp Mysql #1153 - Got a packet bigger than 'max_allowed_packet' bytes

When installing a xampp on mac os Mysql could throw an error #1153 - Got a packet bigger than 'max_allowed_packet' bytes
Solution : Extend the max_allowed_packet size located in Application/Xampp/xamppfiles/etc/my.cnf

On windows systems and linux system the file is called my.ini

mac, mysql, xampp

Drupal 6 : Evil taxonomy hierarchy bug, leaves your hierarchy not working

The vocabulary edit form hardcodes the value of the 'hierarchy' flag to '0', therefore resetting it when the form is submitted and the vocabulary saved. (from drupal.org)
You also need to resave your vocabularies.
You will probably have discovered this bug while working met facetted search.

What should you do?
Change in taxonomy.admin.inc line 172 from

'#value' => '0',

To:
'#value' => $edit['hierarchy'],

core, drupal6

Alter a drupal view footer

My problem was I didnt want php code in my views footer. But I still needed to check if a module existed to call a function of that module.
Here is the hook_views_pre_render, what happens in the function is :
- checking for the correct view and adding content to the footer
- setting the filter format which is the full html id
- setting the empty option

With this function not only the footer could be altered but the entire view could be altered since the views object is present.

/**
 * Implementation of hook_views_pre_render()
 */