CCK text select list with taxonomy terms

del.icio.us Digg! TRACK TOP
Posted on October 6th, 2011 by Administrator. Filed in Drupal.

I thought I would start sharing some snippets of code for some of the drupal projects im working on.  I like many spend more time trying to google around for a solution to a problem and sometimes find a module thats created for the problem or 30 other people posting solutions and some work and some dont.  Then of course I find my self just writing my own stuff based upon some of the data I collected.

Now of course I ran into an issue where I needed to create a form that has a select drop down list of taxonomy terms that when the form was submitted would save the taxonomy tid with this form as a cck field.

So quickly googling around I found Content Taxonomy which created a new cck type to use, but when testing it out I only found that it allows to see the list of terms in one vocabulary.  Well this didn’t fit the bill for me since I needed to display all terms from all the vocabularies in my site.

I went to the api.drupal.com to look at the taxonomy api to see what functions I could use.  It seems that taxonomy_get_tree would get the results I needed.

So I created a new cck field, choose “text” as the field type and select list as the form element.

All the way at the bottom under the allowed values list I have a box that allows me to enter PHP code in.  This allow you to use any php type of code to create a key => value array to return that would then populate your select down down list.

So I know that I only had 5 vocabulary terms I needed to use and the id’s for these where 1-5, you can find these values by going to admin/content/taxonomy and hovering over the edit vocabulary link and it will show in the url the #

So with that in mind I started to quickly code up in my mind how I wanted to do this.

First I wanted to create an array of my vocabulary..

$vids = array(1,2,3,4,5);

Then using the taxonomy get tree api I simply created a foreach loop and pushed the results into a variable named $term.

foreach ($vids as $vid) {

	$output = taxonomy_get_tree($vid,0,-1,1);

	foreach ($output as $out) {

		$term[$out->tid] = $out->name;

	}

}

return $term;

The key thing here is if you want to make sure you get all the terms from the list of vocabulary you run it though another for each loop and assign the output object to the key and value of $term.

$term[$out->tid] = $out->name;\

This is the important part because the $out->tid (term id) is the key of the array and the $out->name is the text that gets displayed in the select drop down list.

With a simple return $term this will then generate a select list populated by term names and the values are the term id’s if you want to store them in your cck field.

Anyhow im sure their are many ways to do this but maybe this helps someone or pushes them in the right direction.

Tagged with:

No comments yet. Be the first to comment!

Create an infographic from your twitter feed

del.icio.us Digg! TRACK TOP
Posted on July 15th, 2011 by Administrator. Filed in Rants and Raves, Tech Stuff.

Visual.ly is a neat site that allows you to create much more interesting visual diagrams than just the plain on pie charts, bar graphs and such, they released the ability to create an infographic from your twitter feed, as you can see mine below… check it out here and scroll to the bottom to get to the twitter link, if you create one leave it in the comments for me to check out.. cheers

 

Tagged with:

No comments yet. Be the first to comment!

DJ Kittens! Great Fucking Video

del.icio.us Digg! TRACK TOP
Posted on July 15th, 2011 by Administrator. Filed in Rants and Raves.

Seems like these kittens can DJ better than some friends of mine.

YouTube Preview Image Tagged with:

No comments yet. Be the first to comment!

Bottling my Kölsch

del.icio.us Digg! TRACK TOP
Posted on July 7th, 2011 by Administrator. Filed in beer.

A few weeks ago I gave a stab at brewing my own Kölsch style ale.  Apprently you cant really call it Kölsch because their is a world wide trade mark so I think companies in the US get away with adding style to the end.

Now Kölsch originated from Koln or Cologne, Germany.  The term Kölsch was officially used for the first time in 1918 to describe the type of beer that had been brewed by the Sünner brewery since 1906.

Anyhow lets get away from the history lesson.  So Im still an amature homebrewer and thought I would give it a shot since well my best friends grew up drinking Kölsch.  I know mine wont compare but well it gives me a chance to try brewing other styles of beer outside of the IPA’s I love.

It took me a few hours to get the initial batch done from boiling the wort (young beer), adding the malt, yeast, hops and finally putting it into my primary fermenter where it should sit at a constant temp for about 7-10 days (this always depends).

After primary fementation is done you transfer it to a secondary and let it sit for a few weeks or so, this really depends on your conditions.   The thing with traditional Kölsch is that its brewed like a ale but fermented lager style where you need to keep it at a very cool consitstant temp for many weeks and some times months.

Now im no expert but on bottling day I decided to rock it out in my PJ’s on a Sunday and bottle my beer.  You can see my timelapse below, it took a picture every 2 seconds.

Anyhow I hope you enjoy the video, I hope to post more often when I have time.

Cheers and happy drinking.

Tagged with:

No comments yet. Be the first to comment!

Calling all web programmers who like beer!

del.icio.us Digg! TRACK TOP
Posted on October 5th, 2010 by Administrator. Filed in beer, Rants and Raves.

I’m in the process of building a new site that focuses around beer and the social culture that this great fine mix of hops and barely create.  If your a drupal developer (modules, themer) etc, drop me a note.

Also any beer fanatics who are really into beer drop me a note I might need some people for beta testing this new site which I hope goes live by the end of the year.

A small tease of the logo, which btw looks great on t-shirts!

Pint Head

Tagged with:

No comments yet. Be the first to comment!

Testing the mew iphone wordpress 2 app

del.icio.us Digg! TRACK TOP
Posted on October 30th, 2009 by Administrator. Filed in Tech Stuff.

In the past I tried to use the first wordpress iPhone app without much success so I’m going to give his a shot and see if t works better .. So this js a simple test post.. Now I need to figure put how to add images

Two images from u2. One of them taken by my best friend..

Tagged with:

No comments yet. Be the first to comment!

Off to Cancun

del.icio.us Digg! TRACK TOP
Posted on July 11th, 2009 by Administrator. Filed in Travel.

Well it’s 4am a d I’m just getting up to catch the bus for my travels to Cancun, Mexico…

This will be my second trip and I’m looking forward to some R&R after 7 months of working on a kick ass game project, which I can’t talk about yet and will post here as soon as I can.

My buddy Jason is meeting me in Mexico since he’s flying in from Canada and this should be an interesting trip.

More as the trip progresses… Stay tuned ….

Tagged with:

No comments yet. Be the first to comment!