This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » call a template from module
expandshrink

call a template from module

call a template from module

Monday 20 October 2014 7:45:42 am - 6 replies

Hi ,How can we call a created template with a module.

I have created a template called test_pgl_logged.tpl. and called it like this and include the page in module.php and site.ini.append as well. But this doesn't work.any one have some comments ?

 

<?php
$Module = $Params['Module'];// Template$tpl = eZTemplate::factory();// HTTP instance$http = eZHTTPTool::instance();echo $tpl->fetch('design:sewtr/Loggedin/test_pgl_logged.tpl');?>

Monday 20 October 2014 8:21:48 am

Hello upeksha,

Can you please share the full path to the template you wish to include?

This will help me guide you to the right way to include it.

Cheers,
Heath 

Monday 20 October 2014 9:12:34 am

Full path is design/standard/templates/sewtr/Loggedin/test_pgl_logged.tpl .Thank you very much. 

Monday 20 October 2014 10:16:44 am

Hello upeksha,

Your template path looks ok except your still not using a design extension (tisk tisk). You must be having some other problem, though I'm not certain what.

Perhaps if you share more information about what your doing we can better understand why your custom module view is not working correctly.

Cheers,
Heath 

Wednesday 22 October 2014 9:12:11 am

Hi upeksha

From your code above, I am not certain that $tpl variable has been initialized as an eZTemplate, the line that does it seems to have been commented out?

Please note that eZTemplate::factory returns an instance of eZTemplate (not Template).

Also note that (from my experience) changes made to custom templates called from custom modules always require cache clearing to be made visible.

Besides these notes, I totally agree with Heath, whenever you have the chance, please share more information on what happens as it does not work.

Cheers,
Io

Wednesday 22 October 2014 10:06:03 am

Hello lo Sol Inf,

upeksha's snippet of code just looks commented out because he just pasted it into the forum message window and did not use a custom tag for source code snippets.

I'm fairly certain that in his code the lines are not commented out and look something like this ...

<?php
 
$Module = $Params['Module'];
 
// Template
$tpl = eZTemplate::factory();
 
// HTTP instance
$http = eZHTTPTool::instance();
 
echo $tpl->fetch('design:sewtr/Loggedin/test_pgl_logged.tpl');
 
?>

Cheers,
Heath 

Thursday 23 October 2014 7:22:53 pm

... and don't forget to declare your extension as a design one. For that you have to define a file in your settings extension directory  : design.ini.append.php

 <?php /* #?ini charset="utf-8"?
# transmit to eZ, to search for designs in your extension
[ExtensionSettings]
DesignExtensions[]=<YourExtensionNameHere>
*/ ?>

Regards.

Alex.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from