I created this simple function in order to print out the commerce order author UID and email.
How may I add the output of the function inside the messages area, without creating a special .tpl? I want that information to be in a special place regardless of the theme implementation.
This is the preprocess function (the only way I manage to get to know if I was inside an order)
function MYMODULE_preprocess_page(&$variables) {
//si estamos dentro de la orden, lo sabemos sólo en función del link en el que estamos!
$uri = request_uri();
$find = '/admin/commerce/orders/';
$pos = strpos($uri, $find);
if ($pos !== false){
//usando if (commerce_order_type_get_name($type = 'order')) no andaba
//obtenemos el número de orden: obtenemos el link con request_uri()
//y de ahí lo explotamos en un array. Sabemos que el número será siempre
//la última parte del link (4).
//usamos commerce_order_load('id de la orden') para obtener el usuario que la completó
$uri = request_uri();
$partes = explode('/', $uri);
$usuario = commerce_order_load($partes[4])->uid;
$correo = commerce_order_load($partes[4])->mail;
$estado = commerce_order_load($partes[4])->status;
echo "<div class='messages status'><a href='/user/".$usuario."'>".$correo."</a> (".$estado.")</div>";
}
}
As you can see, I've tried with this horrible:
echo "<div class='messages status'><a href='/user/".$usuario."'>".$correo."</a> (".$estado.")</div>";
Even when the classes are the same as the rest of the drupal messages, the output keeps appearing at the very top of the page.
How may I do it the right way? (Maybe it necessarily involves template.tpl file?)