chrisspeck.com

Chris' random ramblings

Conditional Gallery2 Shopping Cart Block

I am in the process of developing a photography website, and for that purpose I am combining WordPress + Gallery2.

Gallery2 has a very neat shopping cart feature, which lets a viewer select images, and then purchase/download, order prints, email etc in one go.

Gallery2 comes with a “Shopping Cart Info” block (a design element) which shows the contents of the cart. If selected, this block will display itself, whether or not there is actually anything within the cart.

I thought it looked a little tacky for the site to show a shopping cart on the gallery, and sub-gallery pages when there is nothing in it.

My solution to this issue was to create a new block, called “Conditional Cart Info”, which invokes the original “Shopping Cart Info”, only if the contents of the cart is greater than 0.

It requires a modification to the file /modules/cart/templates/blocks/blocks.inc and the creation of a new file /modules/cart/templates/blocks/ConditionalCart.tpl.

You can download my modified files here or click through below to read the source code:
blocks.inc
ConditionalCart.tpl

 

Read more…

posted by specky in Downloads,Programming and have No Comments

WordPress more tag patch for Facebook Photo Fetcher

I have been experimenting with using the brilliant Facebook Photo Fetcher plug-in (by Justin Klein) to present the photos I have on Face Book however it didn’t work quite the way I wanted.

The specific problem is that there was no way to split a gallery with a <!--more--> tag.

(Having two references to Facebook Photo Fetcher, with a more tag in between does not work either).

So I have edited the source of the plunging to introduce the functionality I need and I have added support for a more=n stanza to the plungin.

The edits (to version 1.2.8 of _output_gallery.php) are as follows:

1. At line 108 insert:

//1.2.8-cs
if( preg_match('/more=(\d+)/', $retVal['startTag'], $matches) )      $retVal['more']      =$matches[1];

2. At line 293 insert:

//1.2.8-cs
//Insert a more tag?
if( $params['more'] > 0 && $i == $params['more'] ) $retVal['content'] .= "<!--more-->\n\n";


An example usage is this:

<!--FBGallery [ID#] more=8 --><!--/FBGallery-->

This will insert a <!--more--> tag after your eighth image. I suggest you set this number to be a multiple of your column count (with default settings, 4 or 8 are good numbers).

If you want you can download a pre-hacked version of _output_gallery.php in a zip file (note this will only work for version 1.2.8 of Justin Klein's plug-in).

Full credit for creating the plugin goes to Justin Klein, I am very grateful to him for sharing it and you may visit his site here, and the plug-in's info and FAQ is here.

posted by specky in Downloads and have No Comments

Neat things with find, LAME and sed in Bash

Just want to chronicle l some really neat, time saving tricks I’ve picked up today for handling files in bash.

The first, how to use the find command:

 find -type f -iname "*.txt"

Easy enough, right?

Let’s use find and cp to back up a bunch of text files:

 find . -name "*.txt" -execdir cp {} a_copy.txt  \;

NOTE: the above assumes that there is only one text file in each directory, and will create a file in the same directory being a copy of whatever file it is that the find command returns.

Let’s string find to sed, and use sed to replace all instances of “.ogg” to “.mp3″ within a collection of text files:

 find . -name "*.txt" -exec sed -i "s/.ogg/.mp3/g" '{}' \;

Let’s also use find and LAME together to convert a batch of wav files to mp3 files (I recommend you run the following from within a screen session):

  find -type f -name "*.wav" -execdir /usr/bin/lame -V3 {} \;

NOTE: The above will create mp3 files in the form of “somefile.wav.mp3″ in the same directory that “somefile.wav” is located.

Let’s use find to delete the remaining wave format files:

 find -type f -iname "*.wav" -delete

The above commands can save hours of messing around with a file manager.

posted by specky in Uncategorized and have No Comments

Joomla to Coppermine sync script

It appears that the Joomla to Coppermine sync script I wrote and gave away in September 2006 is quite popular (judging by the number of 404 errors logged on that particular file). Baring in mind the following points, I offer it to the world for download once more:-

  1. It is a one way synchronisation from the Joomla CMS 1.0.x series membership database to the Coppermine Gallery membership database. The proper way to use this would be to deactivate registrations in Coppermine, and instead rely on the system in Joomla.
  2. Backup your databases before testing it.
  3. I recommend using it only if you are proficient in SQL and PHP
  4. You will need to call this periodically to keep the database in sync (set up a cron job if able)
  5. It is released under the version 2 (or at your option any latter version) of the GPL license and is open source.
There are ten configuration parameters at the top of the script with descriptions of what they do, that you will need to review and change to get it to run on your server.
Your mileage may vary with the current version of Joomla, series 1.5.x. If you are running Joomla 1.5.x, and modify this script to make it run between that version of Joomla and the current version of Coppermine, I would welcome it if you decided to share your code with me – I would, with your permission, upload the same (and give you credit) and offer it for download here.
posted by specky in Downloads,Uncategorized and have No Comments

Site reboot

I thought my previous site was too dreary in aesthetics and far too complicated and difficult to update.

Hence this reboot.

I must say that I am astounded by how easy Word Press is to use!

It is my intention to upload all four posts from the previous incarnation of this site and to add things which I cannot share or index easily through other networks – such as CLI code for Ubuntu,  trouble-shooting guides for Ubuntu or Windows, bash scripts, in depth socio-legal analysis etc.

posted by specky in Uncategorized and have No Comments