Bibli.nl

Peter's blog about cruft and more

Archive for the 'Drupal' Category

10 March
0Comments

Power of the feeds module

Today I have given a small talk about the power of the feeds module in Drupal at Madcap. You can find the presentation here. More info about feeds and how to use it is in this article.

05 February
0Comments

Retrieve real path of file in Drupal 7

Drupal 7 uses the DrupalPublicStreamWrapper-class to handle all the files that are upload to a node or served to the audience. When you take a look at the node object you will see that the path where the file is stored is not directly clear. For example:


[0] => Array (
[fid] => 14
[display] => 1
[description] =>
[uid] => 1
[filename] => index.html
[uri] => public://htmlclean/index_3.html
[filemime] => text/html
[filesize] => 38941
[status] => 1
[timestamp] => 1296904269
)

In this example you can see that the file index.html is saved as index_3.html and available at the URI public://htmlclean/index_3.html. For one off my modules I needed the real path. I will explain how I retrieved it. In the example below the $file_array is the array as shown in the example above.

$scheme = file_uri_scheme($file_array['uri']);
$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
$path = $wrapper->getDirectoryPath() . '/' . file_uri_target($file_array['uri']);

The result of $path is the following: sites/default/files/htmlclean/index_3.html. If you want a web-accessible URL . Simply use file_create_url($uri).

If there is a faster way to do this let me know! Or else you can use this snippet to retrieve the real path of file in Drupal 7.

07 January
1Comment

MediaMosa 2.2 released

As you can see on the website of MediaMosa a new great version of MediaMosa has been released. This version is called MediaMosa 2.2 and has been created totally with Drupal 7. So MediaMosa now has the power of that great new Drupal 7 platform. Drupal 7 itself has only been released as stable for a few days. Information about 2.2 can be found here. Technical changelog can be found here.

18 December
1Comment

Drupal and affiliate marketing

In this post I will explain how you can combine the content management system Drupal with affiliate marketing tools. In the past http://www.bibli.nl was a website showing nodes from several XML feeds containing audio books and magazines. I created this functionality with some custom modules, but often it is better to stick with a combination of community modules to reach your goal. In this case the goal is to import items from a affiliate feed as nodes using contributed modules. But how can we achieve this? Read more…