RSS feed

Nutsmuggling

Micheal Dell vs Steve Jobs: FIGHT!

Apparently Michael Dell is ready to rumble, but some smart commenter put a funny twist on the threaten:

Michael Dell wouldn’t fight Steve Jobs – he would outsource the fight to someone in India.

Memorable.

Apple and the corporate market

Aaron Hillegass on Apple’s attitude towards the corporate world:

Corporation: Hey, does Cocoa include something to help us write apps that talk to our Oracle database?

Apple: Um, nope. But isn’t GarageBand cool?

Corporation: Hmm.

That’s what I call synthesis.

Via informIT.

Windows 7 multi-touch (but you cannot make phone calls!)

In 18 months Windows 7 will do exactly what a iPhone can do today. Seeing is believing:

 

 

The originality of the Redmond folks never ceases to amaze me.

The good news is you won’t have to carry an iPhone with you to look at maps or pinch and rotate your favourite pics. Your monitor and desktop will do.

Via WebMonkey.

 

Addendum: apparently Wil Shipley also found this video funny, and linked to this. Enjoy!

Context free for decoration: a practical example

Context Free is a multiplatform language that allows designer to produce these semi-randomized decorations and animations in a simple way.1This is my most successful attempt a Context Free image:

indian-pattern.cfdg.jpg

I’ve realised this image to decorate yogabenessere.it.

In this brief tutorial I will explain how my Indian pattern is composed by Context free.

Read the rest of this entry »

Notes

  1. It should be noted that, as Loris Zena pointed out, a context free grammar is a specific type of grammar. []

Wordpress: Complex styled menu through custom fields

Custom fields are an amazing and often overlooked feature of Wordpress. The Wordpress codex example of the use of custom fields is’t very inspiring.

Currently Reading: Calvin and Hobbes
Today's Mood: Jolly and Happy

Knowing what someone was reading while writing a post might be interesting, and of course a knowledge of his mood might help to make sense of his rants but hey, is that all? After reading the Codex I archived custom fields in the “Might mean something but presently seems utterly pointless to me” section of my brain.

I had to realise the usefulness of custom fields later.
davidebenini.it, the professional section of this website, features a styled tab menu.

Personal details | Nutsmuggling.png

These tabs link to static pages; more correctly to all the children pages of “Home Page”. These pages’ title are often different from the tab’s label. Thus, “Web Design + Development” links to a page titled “Web Design and Development”. Also, note the different styles of the first and second line of the tab. How to get these tabs from a page dynamically? The answer is, of course, through custom fields.

My main pages feature a couple of custom fields:1

Nutsmuggling › Edit — WordPress-2.png

As you see, they correspond to the first and second line of the title. Setting these fields inside each main page, I can choose a tab-specific title, segmented in two lines.

And now to the code.
For long chunks of code I tend to use the functions.php file in the template folder. This file serves to store functions; you can use it to keep your template files clean.

function white_page_menu() {
    $menu = "<ul id='nav'>";
    $args = array(
    'post_type' => 'page',
    'numberposts' => 5,
    'post_parent' => 10,
    'order' => 'ASC',
    'orderby' => 'menu_order');
    $pageslist = get_posts($args);
    foreach ($pageslist as $post) {
        if (is_page($post->ID)) {
            $menu .= "<li style='display: inline' id='selected'>";
        } else {
            $menu .= "<li>";
        }
        $menu .= "<a href='?page_id=$post->ID'>";
        $custom_fields = get_post_custom($post->ID);
        $first_line_field = $custom_fields['title-first-line'];
        foreach ( $first_line_field as $key => $value )
        $translated_value= p__($value);
        $menu .= "<strong>$translated_value</strong>";
        $second_line_field = $custom_fields['title-second-line'];
        foreach ( $second_line_field as $key => $value )
            $menu .=  p__($value);
        $menu .="</a></li>" /* Fine menu-tab */;
    }
    $menu .="</ul>";
    echo $menu;
}

Then in my template file I just added:

<ul id='nav'><li><a href='?page_id=11'><strong>Personal</strong>details</a></li><li><a href='?page_id=8'><strong>Web Design</strong>+ development</a></li><li><a href='?page_id=9'><strong>Translation</strong>+ localisation</a></li><li><a href='?page_id=22'><strong>Academic</strong>career</a></li><li><a href='?page_id=23'><strong>Traditional</strong>music</a></li></ul>

As you see, my functions calls both title-first-line and title-second-line, and wraps their values into different style tags. This way, if I choose to add another main page to my website, I just have to make it a child of “home-page” and assign it some value to the title-first-line and title-second-line custom fields.

Of course this is just an example of the use of custom fields. You could use them to add a subtitle to you post, or define other specific value that you will call in your template.

Enjoy!

Notes

  1. I have deleted the extra fields for clarity’s sake. []