dimecres, 20 de març del 2013
Posant ombra amb CSS
http://css.flepstudio.org/en/css3/box-shadow.html
Theme override for Upload. module’s attachments list
Interesant post per tunejar els fitxers adjunts a Drupal. Ho hauré de posar en pràctica aviat per un web que estic desenvolupant, ja explicaré com va la experiència.
http://www.island94.org/2008/08/drupal-theme-override-for-upload-modules-attachments-list/
També tenim el mòdul itweak_upload que fa tot això per nosaltres ;) http://drupal.org/project/itweak_upload
Theming i moure elements del peu dels nodes; o cóm crear i modificar variables de funcions
En la meva lluitant per canviar l'aparença de les icones del mòdul Addthis m'he topat amb un interesant artícle que fa una explicació clara i senzilla per extreure la informació d'Addthis del peu del node a un altre zona. Així de pas controleu un xic les funcions de drupal i crear variables ;)
http://www.webenstock.com/es/blog/2011-07-23-theming-mover-enlaces-addthis-arriba-nodo-en-drupal-6x
I un xic el mateix però en anglès, http://snorkers.blogspot.com/2010/05/theming-drupal-node-links.html
llistar termes d'una taxonomia amb la funció taxonomy_node_get_terms
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$node = node_load(arg(1));
foreach ($node->taxonomy as $vid => $term) {
$vn = taxonomy_vocabulary_load($term->vid);
$t[$vn->name][$term->tid]['name'] = $term->name;
}
$output = '';
foreach ($t as $key => $value){
$output .= '<fieldset class="fieldgroup collapsible"><legend>'.$key.'</legend>';
foreach($value as $b => $a){
$output .= '<div class="field-item odd">';
$output .= l($a['name'], 'taxonomy/term/' . $b) . ' ';
$output .= '</div>';
}
$output .= '</fieldset>';
}
print $output;
}
?>
La ide que tenia era aprofitar aquesta funció per fer que Drupal cridés a una icona segóns la taxonomia.
Així que amb l'ajud del bon amic Carlos d'Interdixit hem aconseguit l'objectiu:
<img src="/dev/sites/all/themes/omega/css/img/premsa_ikon<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$node = node_load(arg(1));
foreach ($node->taxonomy as $vid => $term) {
$vn = taxonomy_vocabulary_load($term->vid);
$t[$vn->name][$term->tid]['name'] = $term->name;
}
$output = '';
foreach ($t as $key => $value){
foreach($value as $b => $a){
$output .= $a['name'];
}
} print $output;
}
?>.png">
Font: http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/function/taxonomy_node_get_terms/6
Addthis custom button
La única referència que trobo del mòdul AddThis en quan a la personalització del botó Twitter i qualsevol altre és:
CUSTOMIZATION
You have a number of options available at Administer / Site configuration / Addthis under Button image settingsand Widget settings. Image settings control the button image and widget controls the drop down and window that is opened when user clicks on a link sharing service. More information on how to customize your AddThis button can be found at http://addthis.com/help/customize/custom-button/
If configuration options are not flexible enough for you it is also possible to override
theme_addthis_button in your own theme.Quin merder!
Al final m'ho estic muntant solet a mà, llegint l'api de Twiter i així podem obtenir un codi semblant a:
<code>
<!-- Addthis theming -->
<div id="a9b-tweet-button">
<style type="text/css" media="screen">
#custom-tweet-button a {
display: block;
padding: 2px 5px 2px 20px;
background: url('http://a4.twimg.com/images/favicon.ico') 1px center no-repeat;
border: 1px solid #ccc;
}
</style>
<div id="a9b-tweet-button">
<a class="a9b-tweet-button" href="https://twitter.com/share?url=http://www.eldominidelweb.cat/<?php print $node_url ?>" target="_blank"><img src="/dev/sites/all/themes/omega/css/img/ik_tweetthis_2.png" title="Twitter"></a>
</div>
</div>
<!-- //Addthis theming -->
</code>
Ara a per el de FB ;(
Visualitzar un block només a un tipus de contingut
Not sure if I'm being too reckless, but this seems to be working fine for me, and it certainly looks more efficient in my eyes:
<?php
$node = node_load(arg(1));
$type = $node->type;
return in_array($type,array('my_content_type'));
?>My PHP coding background is certainly more developed than my Drupal background, so please let me know if I'm doing something I shouldn't be doing!
Més exemples i explicacions a: http://drupal.org/node/134425
Un bon apunt per a gent amb poca memòria ;)
Es tracta d'una mena d'apunts on recorda la forma de "tunejar" plantilles (o thems) a drupal. Al igual et sorprèn alguna forma ;)
En resum:
- Copy the existing node.tpl.php file (if you only want to move a few things around) and rename it to node-custom.tpl.php, the "custom" part is the machine readable name you gave your node.
For example: a blog entry would be node-blog.tpl.php - The other way is to simply make a new text file on your computer and name it node.tpl.php, this will give you a completely blank canvas to work with.
Drupal i jugar amb els CSS
CSS; com son de potents però quina murga donen!
Estic, per variar, en un projecte del que requereixo canviar certs CSS depenent de la pàgina (de mateixos tipus de continguts) es visiti, carregui uns o altres CSS.
No sé si serà millor provar algun dels mòduls que el cercador m'indica poden servir per aquesta funció o, per el contrari, passo de tot i fem un php per, segons una condició, canvi el nom de l'estil al div que s'ha d'imprimir..
De moment provaré els mòduls:
Excepcions per a diferents navegadors http://mydrupalblog.lhmdesign.com/theming-search-submit-button-css-cross-browser-compatible-solution
Amb es ous ben fartets d'Omega Theme
A la majoria de Themes de Drupal ja ve tot ben fet al template.php, pero al Theme Omega (que te altres molt bones coses) no hi havia manera de que rutlles.
Despres de mirar i remirar molt he trobat aquest senzill i genial truc:
Hi,
Copy all the code from your page.tpl.php, create a new file called page-default.tpl.php and paste the code in there.
Now delete all the code from your page.tpl.php and add the following:
<?php// Loads the front page templateif ($is_front) {
include 'page-front.tpl.php';
return; }
//Adding custom template based on content typesif ($node->type=='story') {
include 'page-story.tpl.php';
return; }
//if none of the above applies, load the page-default.tpl.php include 'page-default.tpl.php';
return;?>That should work.
El node original a: http://drupal.org/node/296111
Example: Theming a Specific CCK Content Type
Tot l'article a: http://drupal.org/node/266817
Per a tunejar camps de data la cosa es complica i m'ha tingut mitg mati ben ocupat..
<code>
<?php echo $node->field_date_hour[0]['view'];?><br /> (format per defecte de Drupal)
<br /><?php echo date('d M',strtotime($node->field_date_hour[0]['value'])); ?> (Imprimir només dia i mes abrebiat)
<br /><?php echo date('h:i',strtotime($node->field_date_hour[0]['value'])); ?> (imprimir hora i minuts)
Cóm tunejar la plantilla per tenir el link del logo per a cada idioma a Drupal 6 + i18n
The solution in: http://drupal.org/node/608302
Description
instead of
<?phpprint $base_path
?>the link should be
<?phpprint check_url($front_page)?>Lucid menú; un sistema de menú molt configurable per a Drupl
Cóm traduït els formularis de contacte a Drupal (6)
Doncs miratu,
Incloure un block i view dins el contingut d'un node
Insertar un block
Aquest codi fa que s'inserti al contingut el block 49.
Aquest codi inserta el block Google CSE dons el contingut de la pàgina
- Nom del mòdul – Depenent del tipus de block que esteu utilitzant basat en el mòdul que l'ha creat, per exemple el mòdul Google CSE crea un mòdul anomenat "google_cse"
- Delta del block – El "delta del block" essencialment és un número de block, aquest el podeu trobar si posau el cursor sobre el link de configuració d'aquest. http://www.sitename.com/admin/build/block/configure/block/49
Insertar un View
Aquest codi insertarà el view "news_list" dins el "content", aquest agafa la vista per defecte per llistar el contingut.
Aquest insertarà el view "news_list" dins el contingut però utilitzarà la vista "block_1" per mostrar el contingut d'aquest.
Aquest insertarà el view "news_list" dins el contingut però utilitzarà la vista "block_1" per mostrar el contingut d'aquest, però només mostrarà 4 items i només el contingut relacionats amb l'any 2009
- Nom del view – aquest és el nom del views que vols utilitzar
- Nom de la vista – Hi ha moltes formes d'escollir com presentar un view, per això pots especificar quin d'aquestos vols per insertar dins el contingut.
- X - pots especificar en número de items que ha de mostrar aquest view
- Arg – ports especificar arguments per el view si només vols visualitzar certs items; pots afegir multiples arguments tans com suporta el mòdul views (consulta la pàgina del mòdul per descobrir-ne més)