chiamare twig template da controller
Buonasera,
sto proseguendo con il mio modulo in drupal tra un errore ed un altro....
Sono riuscito a fare la route verso il controller, inoltre ho creato pure un semplice template twig
nella cartella templates del modulo, il quale deve essere richiamato dal metodo del controller ma purtroppo ho errore...
Contenuto file di routing gestioneutenti.routin:
gestioneutenti.utenti_form:
path: '/admin/config/gestioneutenti/creaUtente'
defaults:
_form: '\Drupal\gestioneutenti\Form\GestioneUtenteForm'
_title: 'Aggiungi utente'
requirements:
_permission: 'access administration pages'
options:
_admin_route: TRUE
gestioneutenti.mostra_utenti:
path: '/admin/config/gestioneutenti/visualizzautenti'
defaults:
_controller: '\Drupal\gestioneutenti\Controller\GestioneutentiController::content'
_title: 'Gestione utenti ckan'
requirements:
_permission: 'access content'
Contenuto del file controller nella cartella src/Controller/GestioneutentiController.php del modulo:
<?php
namespace Drupal\gestioneutenti\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
/**
* An example controller.
*/
class GestioneutentiController extends ControllerBase {
/**
* Returns a render-able array for a test page.
*/
public function content() {
$element = array(
'#theme' => 'gestioneutenti',
'#markup' => 'Hello, world',
);
// $element['#theme'] = 'gestioneutenti';
return $element;
}
}
Contenuto del file twig nella cartella template:
{#
/**
* Default theme implementation for Views to output a Fullcalendar View.
*
* Available variables:
* - options: View plugin style options:
* - classes: CSS classes.
* - defaultDate: Default date of the calendar
* - start: Field name of start date
* - end: Field name of end date
*
* @see template_preprocess_views_view_fullcalendar()
*
* @ingroup themeable
*/
#}
<div>
<h1>Ciao mondo</h1>
</div>
quando carico il path mi da errore perchè?
Risposte
Prova a postare l'errore che
Prova a postare l'errore che rilevi.