- Publié le 22 Septembre 2009 à 00:31
xzoom fait partie de ces petits outils peu connus mais qui peuvent rendre de grands services. xzoom permet de d'agrandir une zone de l'écran quasiment en temps réel, en d'autres termes, à partir du moment où une zone a été choisie (en glissant sur la zone à partie de sa fenêtre), la fenêtre de xzoom se met à jour en même temps que la zone concernée (à l'inverse de xmag par exemple). Cet outil est une aide précieuse pour le montage / l'intégration HTML/CSS lorsqu'il faut caler des blocs avec plus ou moins de contrastes au pixel près.
L'exemple typique d'utilisation est de mettre la fenêtre toujours au dessus des autres dans un coin de l'écran après avoir choisi la zone sur laquelle zoomer. Il est ensuite beaucoup moins fatiguant de vérifier l'alignement correct de zones précises d'une page par un simple rafraîchissement.
Mes yeux remercient l'auteur de xzoom mais continuent de maudir Internet Explorer :-)
- Publié le 26 Août 2009 à 20:13
I answered this question today on IRC and a colleague asked me the same thing about two weeks ago... it's time to write down the solution :-)
Basically, you just need to tell what design keys you want to use and their value to the template engine of eZ Publish. The design keys are the parameters you will be able to use in an override condition. Let's take an example with a simplistic PHP view (it lacks a lots of checkings) :
<?php
require_once 'kernel/common/template.php';
$NodeID = intval( $Params['NodeID'] );
$node = eZContentObjectTreeNode::fetch( $NodeID );
$tpl = templateInit();
$tpl->setVariable( 'node', $node );
// setting up the context to use override conditions
$res = eZTemplateDesignResource::instance();
$designKeys = array( array( 'class_identifier', $node->attribute( 'class_identifier' ) ),
array( 'parent_node_id', $node->attribute( 'parent_node_id' ) ) );
$res->setKeys( $designKeys );
$tpl->fetch( 'design:mymodule/myview.tpl' );
?>In this code, I define two design keys : class_identifier and parent_node_id, so I can write override rules that match on the class identifier or on the parent node id of the node or on both, for example :
[myview_folder]
Source=mymodule/myview.tpl
MatchFile=myview/folder.tpl
Subdir=templates
Match[class_identifier]=folder
With this override condition, eZ Publish will use the template located in override/templates/myview/folder.tpl in the design when the node is a folder, otherwise it will use the default one (templates/mymodue/myview.tpl).
- Publié le 19 Août 2009 à 23:03
J'ai découvert il n'y a pas très longtemps la fonction eZContentFunctions::createAndPublishObject() de l'API eZ Publish. Cette fonction bien cachée (et enfin documentée depuis la résolution de ce bug) permet de créer facilement des objets de contenus. Quand je pense que tout le travail est mâché par cette fonction, ça en fait des lignes de codes inutiles... Par exemple, pour créer un objet de la classe de contenu File, ces quelques lignes suffisent :
<?php
$params = array();
$params['parent_node_id'] = 52; // node id of /Media/Files
$params['class_identifier'] = 'file';
$params['creator_id'] = 14; // admin
$params['storage_dir'] = '/tmp/data/'; // don't forget the ended /
$params['section_id'] = 3; // section media
$attributesData = array();
$attributesData['name'] = 'My file';
$attributesData['file'] = 'my_file.txt';
$params['attributes'] = $attributesData;
$contentObject = eZContentFunctions::createAndPublishObject( $params );
?>
Chaque élément du tableau $attributesData contient les valeurs des attributs du futur objet de contenu sous le format attendu par la méthode fromString() de chaque datatype. Et voila, ce n'est pas plus compliqué que ça ! Dommage qu'il n'existe pas encore l'équivalent pour mettre à jour les objets de contenu existants.
- Publié le 11 Mars 2009 à 14:03
Petit pense bête pour la prochaine fois où j'aurai besoin de faire la somme d'une liste de nombres en shell (un nombre par ligne) :
cat my_file | awk '{total+=$1}END{print total}'Par exemple, pour obtenir la taille totale des tables dans une base de données MySQL :
mysqlshow -i my_db '*' | tr -s ' ' | cut -d ' ' -f 14 | grep [0-9] | awk '{total+=$1}END{print total}'
- Publié le 16 Novembre 2008 à 23:53
The eZ Publish debug is probably one of the most useful tool for the eZ developer. It is recommended to always activate it during development as you should read in it only debug or notice messages (and perhaps some translations warnings).
Enable the debug ouput
I usually activate it by putting those lines in the site.ini.append.php of the siteaccess I work on :
[DebugSettings]
DebugOutput=enabled
[TemplateSettings]
ShowUsedTemplates=enabled
Those settings activate the debug and display the templates used to render the page which is often a very useful information.
Don't show debug to everybody
It is also possible to restrict the generation of the debug by IP or by user id. This feature can be useful to monitor a live sites or to not annoy your colleagues when developing a site. With the following settings, the debug is only displayed for users visiting the site with the IP 10.2.2.157 :
[DebugSettings]
DebugOutput=enabled
DebugByIP=enabled
DebugIPList[]=10.2.2.157
Comment the line beginning by DebugIPList will make the debug disappear for everybody.
What happen before the redirection ?
DebugRedirection setting lets the developer read debug messages before an HTTP redirect. Instead of being directly redirected, you have to click on a button to view the next page. It can be useful to debug workflow events, content edit handler or extensions with modules and views... It is also possible to specify paths in this setting to enable this feature for only some pages, but this feature is undocumented for the moment.
Place the debug to not break your page
The default behaviour of eZ Publish is to replace the string <!-- DEBUG_REPORT --> by the debug output. If the string is not in the HTML code of the page, the debug will be placed at the end of the page. So depending on the HTML code, it's important to place correctly the string <!-- DEBUG_REPORT --> to not break the page with the debug.
Disable the debug for some special pages
As seen just before, <!-- DEBUG_REPORT --> is replaced by the debug output, so it's easy to comment <!-- DEBUG_REPORT --> another time in the pagelayout so that the debug is commented in some special pages for example in AJAX parts of a page or in exports based on a special layout. More details in Disable debug for custom layouts (/layout/set/xyz) topic in eZ.no forums.
Output something in the debug from a template
debug-log is an undocumented template operator that lets the developer output a variable and/or a message to the debug output. It's just an eZDebug::writeDebug call. It is sometimes easier to read and less obtrusive than using the attribute() operator, I use it in eZ Class Lists 1.0 to display the hash used to filter objects list with something like :
{debug-log msg='template fetch filter' var=$filter_hash}