Last active
June 26, 2020 03:31
-
-
Save camoa/4561530b69243738da6dafa8ad0ddfe5 to your computer and use it in GitHub Desktop.
D728: Task-24 Define a custom template for module output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> This is the lotus template with a value of {{ test_var }} </p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_theme() to add the template definition. | |
**/ | |
function lotus_theme($existing, $type, $theme, $path) { | |
return array( | |
'lotus_template' => array( | |
'variables' => array('test_var' => NULL), | |
), | |
); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file | |
* Contains \Drupal\lotus\Controller\LotusController. | |
*/ | |
namespace Drupal\lotus\Controller; | |
use Drupal\Core\Controller\ControllerBase; | |
class LotusController extends ControllerBase { | |
public function content() { | |
return array( | |
'#theme' => 'lotus_template', | |
'#test_var' => $this->t('Test Value'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment