Aug 4
Linux, CIFS, and the Nas200…
There isn’t much information in regards to how to utilize the Nas200 from linksys with a Linux operating system. Lets look at the facts of the situation here. Linux allows many different file systems to be mounted: SMB, NFS, CIFS, etc.. The Nas200 supports CIFS, bingo bango we got a match here!. So lets take for example that you have your Nas200 sitting at 192.168.1.5 and the folder you want to mount is “anthony”. Your mount command would look like this:
sudo mount -o user=anthony //192.168.1.5/anthony /media/nas200/
Now this assumes that /media/nas200 is a valid directory. You have just mounted your Nas200 and any respectable media player (Amarok) can now see your mounted drives and stream your music. Very cool stuff indeed! You can even add it to an alias in an *.rc file so you can mount it on a whim! Thanks to jervine@#suse on freenode for the help!
No commentsAug 1
Testing my LightBox plugin…
Why not showcase some music and a new wordpress plugin. Lightbox is awesome. Just click on the image below:
But also check out his set on MCAST exclusively on mercuryserver.com
No commentsAug 1
FAPI Quick Tips
Pre selecting a select list in Drupal is not as easy as it seems. First take a look at the following array:
$form['contacts'] = array( ‘#type’ => ’select’, ‘#multiple’ => TRUE, ‘#size’ => ‘6′, ‘#title’ => ‘Contacts’, ‘#options’ => $contacts, ‘#default_value’ => $def_contacts );
There are a couple of things to take notice here. ‘#options’ is the total list of options in the array so lets say ‘$contacts’ looks like so:
$contacts = array( 'foo' => 'bar', 'foi' => 'baz', 'john' => 'digweed', 'sasha' => 'has no last name' 'steven' => 'segal' );
You have an array with the following keys: foo, foi, john, sasha, and steven. Say we wanted to preselect ‘digweed’ and ’segal’ this is where we build ‘$def_contacts’. The key (no pun intended) to having Drupal preselect items in the select list is to pass the keys of the ‘$contacts’ array in an array itself. So if we wanted to have the form preselect existing items that might be part of a node or coming from a database we could build ‘$def_values’ as this:
$def_values = array('john', 'steven');
This all seems very simple but it takes a little time to understand as it is well hidden underneath those Drupal API docs.
No commentsJul 9
Drupal conventions plain and simple.
There are some common misconceptions about doing certain tasks in Drupal. I take the following to be more of a random collection of thoughts about Drupal and some of the explanations behind them. Lets take for example the CCK node types and forms.
When you build in the CCK you are building a node type but some things are not apparent such as how do I access the CCK node type form on another page? The answer is not simple because the documentation is sparse in this area. I have found that if you want to call a CCK node add/edit from you can do so by appending the machine readable name of the node with “_node_form”. So for example lets say we have a CCK node type with the label “article” the internal form name would be “article_node_form”. Now to call a form is very simple, all you have to do is
function show_me($node_id)
{
$output = ”;
$article_node = node_load($node_id);
$output .= drupal_get_form(’article_node_form’, $article_node);
return $output;
}
As you can see pre-loading any form with a node is just a simple matter of loading the node and then passing it as a second parameter. It took me quite a while to dig through the API and the docs on drupal.org to figure this out.
Additionally theming the form elements is also very trivial once you sift through the documentation You can create a theme function that takes the form as a parameter. So we have our CCK form and we can theme this just like any other form. Usually this is done by pre-pending “theme_” to the form name in our case “article_node_form”. The completed function name would be “theme_article_node_form” For example:
function theme_article_node_form($form)
{
// render specific elements of the form.
$output .= drupal_render($form['title']);
// most important is to render anything additionally such as submit hooks
$output .= drupal_render($form);
return $output;
}
The key to the “theme_” hook is that you can do anything with the form elements and combine them with html attributes. Take for example this complete example of a theming function I built to put certain elements in a table:
function theme_advertisement_node_form($form)
{
$output = ”;
$output .= drupal_render($form['title']);
$output .= drupal_render($form['field_campaign_reference']);
$output .= drupal_render($form['taxonomy']);
foreach($form['field_editions']['keys']['#options'] as $eid => $edition)
{
// get the machine label for the edition
$edition_info = db_fetch_array(db_query(”select label from {edition} where name=’%s’;”, $edition));
$row = array();
$row[] = drupal_render($form['field_editions']['keys'][$eid]);
$row[] = drupal_render($form[$edition_info['label']]['revenue']);
$row[] = drupal_render($form[$edition_info['label']]['offset_revenue']);
$row[] = drupal_render($form[$edition_info['label']]['no_commission']);
$rows[] = $row;
}
$table_header = array(
array(’data’ => ‘Edition’),
array(’data’ => ‘Revenue’),
array(’data’ => ‘Offset Revenue’),
array(’data’ => ‘No Commission’)
);
//$output .= drupal_render($form['field_editions']['keys']['#title']);
$output .= theme(’table’, $table_header, $rows);
$output .= drupal_render($form['field_flight_date']);
$output .= drupal_render($form['field_required_sends']);
$output .= drupal_render($form['field_cpm']);
$output .= drupal_render($form['field_total_revenue']);
$output .= drupal_render($form['field_creative_approved']);
$output .= drupal_render($form['field_invoiced']);
$output .= drupal_render($form['image_attach']);
$output .= drupal_render($form['submit']);
// unset any form elements we didn’t use
unset($form['field_editions']);
$output .= drupal_render($form);
return $output;
}
That should wrap anything in regards to theming and working with CCK node types.
No commentsJul 3
To drupal or not to drupal that is the question…
So I was debating using Drupal which we are basing the company that I work for enterprise site or just scrap the existing WordPress and do a fresh install with a new theme. Well if you can’t tell I went with the latter. So I have been busy learning the nuances of Drupal 5.7 and have come to the following conclusion.
1. It is some what great, major companies use Drupal and accomplish great things.
2. You can do some cool stuff with it, even build some excellent modules.
3. You can also learn to bang your head against the damn wall…
Numero tres is more of a product of you staring at the api.drupal.org site, your code, back a the api.drupal.org site, then your code, asking your boss why it might not work (not that he is a Drupal master of course), then going onto #drupal on Freenode and not finding the info, then going back to your code realizing you have spaces in your array keys, then you fix it…
So that is it in a nut shell. If you are feeling quite peckish, take a look at Sasha & Digweeds set over @ mercuryserver.com. Shizzle my nizzle.
No commentsJul 3
Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
No comments
