Skip to main content
Drupal Dev

Main navigation

  • Home
  • Users
  • Demo: Events
User account menu
  • Registrati
  • Log in
By admin, 25 October, 2016

Come modificare il template di edit/add di un nodo

Inserire il seguente codice nel file template.php

function [THEME_NAME]_theme() {
  return array(
    'NODETYPE_node_form' => array(
      'arguments' => array(
          'form' => NULL,
      ),
      'template' => 'tpl/NODETYPE-node-form', // set the path here if not in root theme directory
      'render element' => 'form',
    ),
  );
}

 

creare il file NODETYPE-node.form.tpl.php ed inserire la seguente riga

 

Tags

  • Template
  • Node
  • Edit
By admin, 18 October, 2016

Differenti template in base all'url della pagina

Da inserire nella funzione [THEME_NAME]_preprocess_page()


// Page template suggestions based off URL alias
   if (module_exists('path')) {
    $alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
    if ($alias != $_GET['q']) {
      $template_filename = 'page';
      foreach (explode('/', $alias) as $path_part) {
        $template_filename = $template_filename . '__' . $path_part;
        $variables['theme_hook_suggestions'][] = $template_filename;
      }
    }
  }

 

Tags

  • Template
  • URL
By a.petrocelli, 14 June, 2016

Come scrivere nel file di Log dal tuo codice (plugin o altro)

watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)

 

Esempio di chiamata:

watchdog('il tuo modulo', 'Descrizione',array(), WATCHDOG_INFO);

 

Parametri

$type: The category to which this message belongs. Can be any string, but the general practice is to use the name of the module calling watchdog().

Tags

  • Logfile watchdog
By admin, 17 May, 2016

Inserire i social share nei contenuti da node.tpl.php

Molto utile è avere la stringa intera per lo share dei contenuti sui vari social.
Questo è un esempio di come inserire la stringa con i parametri in modo da ottenere il link corretto per la condivisione dell'attuale nodo.

Facebook

Tags

  • Social Share
By admin, 17 May, 2016

Come creare un custom breadcrumb per contenuti OG Group con il modulo path breadcrumb

  1. Aprire Structure > Path Breadcrumbs
  2. Cliccare su "create new path breadcrumb
  3. Dare il nome nel campo "Breadcrumb definition"
  4. Nel path inserire "node/%node"
  5. In Argouments scegliere ""Content: ID
  6. In selection rules scegliere "Node: type" e nel popup successivo selezionare il type del nodo al quale applicare il breadcrumb
  7. Inserire il valore "%node:og-group-ref" per il titolo
  8. Inserire il valore "%node:og-group-ref:0:url" per l'url

 

Tags

  • Breadcramb
  • OG Group
By admin, 27 April, 2016

Semplice esempio per costruire una tabella da codice

Questo esempio esegue una query per ottenere il numero dei post diogni gruppo (OG)

Tags

  • OG Group
  • Embed
  • Table
By admin, 11 April, 2016

Come creare una pagina di redirect per la contact form di Drupal

Inseire queste due funzioni nel file template.php del tuo tema

function [THEME_NAME]_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'contact_site_form') {
        $form['#submit'][] = 'contact_form_submit_handler';
    }
}

function contact_form_submit_handler(&$form, &$form_state) {
    $form_state['redirect'] = 'thank-you-page';
}

 

PS: thank-you-page è l'url alias di una pagina creata da backend.

Tags

  • Contact form
By admin, 22 March, 2016

Come formattare una data ti tipo Date

Giorno

<?php print format_date(strtotime($node->field_events_date['und'][0]['value']), 'custom', 'd');?>

Mese

<?php print format_date(strtotime($node->field_events_date['und'][0]['value']), 'custom', 'm');?>

Anno

<?php print format_date(strtotime($node->field_events_date['und'][0]['value']), 'custom', 'y');?>

 

Se la data ha un end date allora

 

Tags

  • Date
By admin, 7 March, 2016

Inserire un blocco views da codice

La sintassi per insierire un blocco creato con views da codice php è:

<?php print views_embed_view("[NOME_VISTA]", "[NOME_BLOCCO]",[ARGOMENTO]); ?>

 

[NOME_VISTA] = Machine name della vista

[NOME_BLOCCO] = Machine name del blocco (es: block_1, block_2 etc.)

[ARGOMENTO] = Opzionale

Tags

  • Block
  • Views
  • Embed
By admin, 1 February, 2016

Funzione prev - next per contenuti node referenziati

Inserire questa funzione nel file template.php del vostro tema

Tags

  • Prev/Next
  • Node Reference

Pagination

  • First page
  • Previous page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Page 5
  • Page 6
  • Page 7

TagCloud

Twig(7) Template(6) composer(5) Debug(4) CSS(4) Embed(4) Views(4) php(3) Taxonomy(3) Image Style(3) form(3) redirect(3) drupal8(3) Edit(3) Node(3) Block(3) Parameter(2) Custom Theme(2) Expose Filter(2) Fields(2) User(2) Profile(2) Field image(2) drush(2) cache(2) moduli(2) Grafica(2) Bootstrap 3(2) URL(2) Social Share(2) OG Group(2) Custom (1)node.html.twig (1)php8 (1)controller (1)Alias (1)Path (1)Node Reference (1)Prev/Next (1)Installazione (1)database error (1)Pagina errore (1)Maintenance page (1)theme debug tpl (1)variable_get (1)select (1)dropdown (1)Title (1)Menu (1)Settings Theme (1)symphony (1)global (1)global variable (1)widget (1)responsive (1)Youtube (1)Tree (1)Sub-category (1)Category (1)tag HTML (1)Webform (1)console (1)dev (1)Style (1)Images (1)Pictures (1)Search form (1)gestione stringhe (1)truncate (1)stile immagine (1)link immagine (1)tassonomia (1)bug-fixing (1)diff (1)patch (1)Core (1)hook (1)yml (1)libreria (1)js (1)tema (1)comandi (1)hostname (1)entity (1)ruoli (1)rules (1)login (1)RUBY (1)Compiler (1)SASS (1)SCSS (1)Field embed (1)Grid (1)Logfile watchdog (1)Breadcramb (1)Table (1)Contact form (1)Date (1)
RSS feed