WordCamp Irlanda (2): Rethinking themes // WordCamp Irlanda (2): Rethinking themes

Daryl
Daryl

La primera conferencia de la WordCamp en el Tech Track fue la de Daryl Koopersmith. Daryl estaba allí para hablarnos de Elastic Theme.

Fue una buena entrada para la WordCamp. Un comienzo muy potente e interesante que nos dejó a todos con muy buen sabor de boca, tanto por lo que nos contaron, como por la demostración de cómo son las cosas: Daryl, un estudiante desconocido, ahora es parte de Automattic y está trabajando a pleno rendimiento con ellos. Y es que en Automattic no dejan que el talento se vaya corriendo. Hacen que se quede con ellos, y que siga creando valor añadido.

Pero vamos a lo que nos interesa. Rethinking themes.

Daryl
Daryl

The first WordCamp conference in the Tech Track was the one from Daryl Koopersmith. Daryl was there to talk us about the Elastic Theme.

It was a very good intro for the WordCamp. A very strong and interesting beginning which gave a very good impression to all of us. First, because all the things that we learned from his speech. And second, for the demonstration about how cool life can be: Daryl, an unknown student one year ago, now is a part of Automattic and is working full-time with them. That’s because Automattic doesn’t allow talented people run away. They made them to stay and continue creating valuable stuff.

But let’s go to the interesting part. Rethinking themes.

Quién es Daryl

Daryl (@drylk) es un estudiante de la Universidad Washington en St. Louis que el año pasado decidió participar en el Google Summer of Code (una especie de campamento para programadores) donde estuvo trabajando en un nuevo Theme Framework para WordPress.

Qué es el Google Summer of Code

GSoC es un proyecto mundial que ofrece a estudiantes que sean desarrolladores la posibilidad de escribir código para proyectos software de código abierto. En GSoC han trabajado con muchos proyectos de código abierto y software libre.

La idea de GSoC es que un participante pueda tener un mentor para trabajar en un proyecto que haya elegido libremente. Por supuesto, eso le dará mucha experiencia y le brindará muchas posibilidades de quedarse en la empresa después.

En Automattic también se ofrecen proyectos en el GSoC, de forma que un desarrollador puede tener como mentor a Andy Peatling, Andy Skelton, Austin Matzko, Beau Lebens, Dion Hulse, Donncha O’Caoimh, John Godley, John James Jacoby, Joseph Scott, Mark Jaquith, Nikolay Bachiyski, Noel Jackson, Peter Westwood, Ryan Boren, Thorsten Ott, Jane Wells o al propio Matt Mullenweg. Cada uno de ellos es especialista en un apartado de WordPress (podéis consultar la lista de mentores aquí) y ayudarán a sus estudiantes en todo lo que puedan.

Daryl participó en el GSoC de 2009 en el apartado de Themes Framework. Y en esta conferencia nos ha mostrado sus resultados.

Qué es un Theme Framework

Un Theme Framework es algo así como un constructor de temas. Es decir, es una herramienta muy flexible que se puede utilizar para crear nuevos temas.

En la última actualización de WordPress se ha incluido algo que llevábamos tiempo usando en la sombra y que ahora está adquiriendo toda su relevancia: los temas hijos. El uso de frameworks hace el trabajo mucho más sencillo y reduce (en mucho) el tiempo que empleamos en crear el tema. Dejamos, pues, el uso duro de PHP con los WordPress Template Tags.

Un framework, como veremos, puede venir en dos sabores: como tema base, o como plugin.

Los temas hijos

Un tema hijo es un tema que tiene padre. Es decir, que se nutre de él.

Para explicarlo de una forma más simple, es un tema que hereda su funcionalidad del padre. Así, nosotros podremos crear un tema hijo a nuestro gusto utilizando las funcionalidades de padre (llamándolas), y si éste se tiene que actualizar, lo hará de forma transparente sin afectar en absoluto al tema hijo y sus cambios.

El Elastic Theme

El tema elástico (Elastic Theme) fue un proyecto que Daryl desarrolló durante el Google Summer of Code de 2009.
Con él, lo que nos intenta mostrar es la consecución final de todo lo que busca busca WordPress adaptado a un tema: más libertad para los usuarios y para los desarrolladores.

El tema elástico tiene:

  • Estructura por niveles (ya hablaremos en próximos artículos del tema), lo que reduce mucho el trabajo.
  • Las repeticiones de código se reducen usando jerarquías, modificando únicamente pequeños bloques. Utiliza mucho el famoso algoritmo divide y vencerás, sobre todo en el loop.php.
  • WordPress 3.0 nos trae nuevas funciones que nos hacen más sencillo trabajar con temas. Una de ellas es get_generic_template(). Con ella podemos hacer llamadas como get_generic_template(‘loop’,’author’).

Podemos sacar en claro que ahora los temas están creados:

  • Como si fueran mini-páginas
  • Como hijos de un tema principal
  • Siguiendo una estructura jerárquica

Esa misma estructura jerárquica es la que hace que los temas sean más usables, ya que si tenemos un bloque que se repite podemos convertirlo en un módulo.

El motor del Elastic Theme

¿Quieres verlo en acción? Aquí tienes el vídeo.

El Elastic Sandbox ofrece:

  • editor de temas en vivo
  • un editor de estilos muy ligero
  • temas modulares

Consideraciones para programadores

  • Léete el código de WordPress. Úsalo. ¡Aprenderás un montón!
  • Usa el trac, phpxref y el Codex. ¡Sigue aprendiendo!
  • Experimenta. Ahora tienes dos nuevas funciones que te hacen la vida más fácil. Son nuevas en 3.0 y modifican la query. Y, lo mejor de todo, se ejecutan antes que el tema.
  • Ahora podemos crear mashups usando WordPress de forma sencilla.
  • ¡Tenemos un editor visual de temas! Lo que permite infinitos diseños.
  • Al programar un tema, ten en cuenta que cualquiera debe poder modificar cualquier valor por defecto que hayas puesto.
  • ¡Piensa en módulos!

Atualización (10/05/2010) Aquí está el vídeo de la charla:

Who is Daryl

Daryl (@drylk) is a computer science student from Washington University at St. Louis. Last year he decided to participate in Google Summer of Code (a programmers camp) where he was working in a new Theme Framework for WordPress.

What is Google Summer of Code

GSoC is a mundial project which offers to students who are developers too the opportunity of write code for open source software projects. GSoC have got lots of open source and free software projects.

The idea surrounding GSoC is that the attendants could have a mentor to work in a project chosen. It will give them a lot of experience and lots of opportunities to work in the desired company.

In Automattic there are projects in GSoC too. It means that a developer can have to Andy Peatling, Andy Skelton, Austin Matzko, Beau Lebens, Dion Hulse, Donncha O’Caoimh, John Godley, John James Jacoby, Joseph Scott, Mark Jaquith, Nikolay Bachiyski, Noel Jackson, Peter Westwood, Ryan Boren, Thorsten Ott, Jane Wells or Matt Mullenweg like a mentor. Each one is specialist in a WordPress field (you can see the complete list of mentors here) and they will help their students in everything they can.

Daryl was one of this students in 2009 GSoC, more precisely in Themes Framework field. And in this conference he showed us his achievements.

What is a Theme Framework

A Theme Framework is a theme constructor. It’s a very flexible tool that can be used to create new themes.

In this last WordPress update we can find a new relevant tool: child themes. Using frameworks makes our work much more easy and reduces the time that we spend in creating our themes. That means that we stop using PHP and the WordPress Template Tags reference for everything.

A framework can be presented in two flavours: parent theme or plugin

Child themes

A child theme is a theme with a father: It uses functions and other characteristics directly from him.

We can create a child theme and use all the functions that we need casting from the parent theme. And if we need to update the parent theme, it will update without harming our child theme and our changes.

The Elastic Theme

The Elastic Theme is a project that Daryl developed during Google Summer of Code in 2009.

And what he wants to achieve is what everyone is looking in WordPress, adapted to a theme: freedom for users and developers.

The Elastic Theme has:

  • Level-structure, which reduces work a lot. We’ll talk about it in next posts.
  • Code repetitions are reduced using hierarchy, modifying only small blocks of code. It uses the infamous divide-and-conquer algorithm. One small sample is the archive loop.php.
  • WordPress 3.0 has new functions which makes easier our work with the themes. One of them is get_generic_template(). Using it we can do calls like get_generic_template(‘loop’,’author’).

We can do a small resume about the new way of creating themes:

  • They are created like mini-pages.
  • They are children of principal (parent) themes.
  • They have a hierarchy-level structure.

This hierarchy-level structure makes the themes more usable, because if we have a block which repeats itself we can convert it in a module.

The Elastic Theme engine

Do you want to see it in action? Here’s the video.

The Elastic Sandbox offers:

  • Live theme editor.
  • Light style editor.
  • Modular themes.

If you are a developer

  • Read the WordPress Code. Use it. You’ll learn a lot!
  • Use trac, phpxref & Codex. Continue learning!
  • Experiment. Now you have two new functions which will do your life easier. They are brand new in 3.0 and modifies wp query. And, best of all, they execute before the theme.
  • Now we can create mashups using WordPress in an easy way.
  • We have a visual theme editor! It allows infinite layouts.
  • When programming a theme you must get in mind that everyone must be allowed to modify any default value.
  • Think modular!

Update: This is the video:

2 respuestas a «WordCamp Irlanda (2): Rethinking themes // WordCamp Irlanda (2): Rethinking themes»

  1. Avatar de José Conti

    Encuentro impresionante el Elastic Theme.

    Supongo que nadie te salva de tener que retocar el css para los colores, fondos, etc… ¿no? ¿o también hay algún apartado?

  2. Avatar de RaveN

    Por ahora no. Todo llega, Daryl tiene muchas ideas para este framework :).