Sten Posted August 3, 2019 Posted August 3, 2019 Hi Regesh, Do you have the latest version of ProcessWire ? Did you try to install a previous version ?
Wanze Posted August 3, 2019 Author Posted August 3, 2019 11 hours ago, regesh said: Can't use this module if select any parser (smarty or twig) Fatal Error: Uncaught Error: Class 'Twig_Loader_Filesystem' not found Hi @regesh Wrote you back on GitHub, hope it helps: https://github.com/wanze/TemplateEngineTwig/issues/22 Cheers
regesh Posted August 15, 2019 Posted August 15, 2019 Thanks. As i wrote on github, i started project with v1 of this plugin. So there is no time to check. After i'll finish, i'll test. Thanks again.
porl Posted January 14, 2020 Posted January 14, 2020 Hi there. Not sure if my problem is specific to the twig engine or to this factory module. If I enable automatic rendering, I have no issues, however if I turn it off (and call the render function as follows), I can't use any '%' character in the template or in Processwire fields. The render function is called like this: Quote $factory = $modules->get('TemplateEngineFactory'); printf($factory->render($page->template->name, $twigVars)); $twigVars is just an array I'm passing it (and tested working fine). I have tried using Twig with raw php (no processwire) and the templates render fine (obviously without ProcessWire functionality), so I believe the $factory->render function may be trying to interpret the '%' character in some way. The % character is fine to use within twig tags (including using {% and %}), but anywhere else the method just returns null. I tried replacing these lines with calls to twig directly, which rendered the template fine, however it is unfortunately not a workaround for me as my templates are making calls to other page render functions (this is why I can't use auto render) and those are not getting the php template files called correctly as twig obviously doesn't know about this.
porl Posted January 15, 2020 Posted January 15, 2020 Never mind, I refactored the site to be able to use the auto-render function and it solves the issue.
Mikie Posted February 5, 2020 Posted February 5, 2020 Hey @Wanze. I am wondering if I could request an additional empty "config" array in the render method. This would let TemplateEngine modules do some more logic their end, eg override module config settings. The reason for this is for whatever reason I seem to find myself wanting to render template partials without worrying about or needing the global data object (just explicitly pass params), however I would also like the global data object populated generally. Eg... <?php $factory->render('partial', ['foo' => 'bar'], ["global_data" => false] ));
Mikie Posted February 16, 2020 Posted February 16, 2020 In reply to the my post above, disabling automatic rendering in the Factory lets me render pages / templates however I want. Much more flexible imo, and solves my issue. 1
toni Posted April 12, 2020 Posted April 12, 2020 Hi, I'm using the excellent Template Engine Factory from @Wanze and Smarty. One thing I can not figure out is how to use pw's `__('…')` translate function within my templates. This is how I tried: /site/templates/views/fundus-index.tpl <a href="{$page->httpUrl}">__("zurück")</a> <a href="{$page->httpUrl}">{__("zurück")}</a> I would expect to find `fundus-index.tpl` in translatable files. Unfortunately it does not show up even after refreshing the list (screenshot attached). When trying to enter the file directly I get a warning saying: ProcessLanguageTranslator: That file has no translatable phrases After that I've tried to setup a new php file `/site/translations.php` with content `__("zurück")`. This file shows up and I can successfully translate the string which I would expect that this string is globally available across all files (missing knowledge regarding the usage of translations ;) However my template file does not care about this newly created translation. So long story short. How can I use translations in smarty templates? Best regards, Toni 1
toni Posted April 12, 2020 Posted April 12, 2020 this can be closed (cannot find a close button ? time to shut down the computer.)
teppo Posted April 13, 2020 Posted April 13, 2020 10 hours ago, toni said: this can be closed (cannot find a close button ? time to shut down the computer.) Hey @toni! There's no close action on the forum, but I'm going to merge this topic with the TemplateEngineFactory support board — the recommended approach is that if you have questions regarding specific module, you should post them on the support board for that module. You can find the correct board via the modules directory (there's a "support board" link in the sidebar for each module) ?
markus_blue_tomato Posted April 13, 2020 Posted April 13, 2020 22 hours ago, toni said: peng : Maybe this can also help you. I wanted to make the Smarty Files translatable, but endend up into building an converter (build with node.js) which generates .php files which can be translated in the pw admin panel
toni Posted April 30, 2020 Posted April 30, 2020 On 4/13/2020 at 8:57 AM, teppo said: Hey @toni! There's no close action on the forum, but I'm going to merge this topic with the TemplateEngineFactory support board — the recommended approach is that if you have questions regarding specific module, you should post them on the support board for that module. You can find the correct board via the modules directory (there's a "support board" link in the sidebar for each module) ? Nice! Thank you @teppo
gornycreative Posted July 4, 2020 Posted July 4, 2020 Under certain circumstances, it looks like Template Engine Factory will prevent HTML from rendering on 3.0.161. I had it installed with the Twig addition and nothing would render properly (meaning at all) on the front end until I removed it.
FireWire Posted August 11, 2020 Posted August 11, 2020 Having a rough go with performance and figuring out how to diagnose issues. I noticed that as I was building out a template that the load times on my local dev environment continued to get slower and slower. Basically slower than browsing the internet. I recently picked up the Pro DevTools modules and started working from the Profiler and the results have been pretty bad. I'm using the Twig Template Engine. It is taking ~1.5 seconds for the server to render the page before returning anything to the browser. I started to work backwards through my code and I cannot find where there would be issues that should be causing this much of a slowdown, I wasn't able to get speed differences by disabling modules and I don't think that I'm running anything that would conflict. I went through my templates and partials and started commenting out loops. I have a few loops on the home page to render picture grids, a blog feed, and navigation in both the footer and the header. There aren't any calls to modules or special functions that are happening inside these loops. When studying the output of Profiler there's no indication that anything is booting up during the page rendering process either. By commenting out all of the loops it dropped the render time from ~1.5s to .3-.5s, which is still slow for ProcessWire. I've attached two screenshots of the Profiler output for comparison. Everything below the cutoff in the picture had zero execution time. I'm not experiencing any slowdown on other local sites. Appreciate any help! Currently running: ProcessWire 3.0.164 Master TemplateEngineFactory v2 TemplateEngineTwig v3 PHP 7.3.13
Frank Vèssia Posted October 22, 2020 Posted October 22, 2020 I'm trying to change template on the fly (when there is a urlSegment in homepage) and I'm almost there (I guess), the behaviour is strange, the markup is working but if I print the template name I get the home page, something is not working properly The code is inside a custom module. Thanks for the help. I'm using v1 (can't use v2) public function ready() { $this->addHookBefore('Page::render', $this, 'hookProfiles'); } protected function hookProfiles($event){ $page = $event->object; if($page->template == 'home' && wire('input')->urlSegment1 != ''){ $page->template->set("filename","/site/templates/author.php"); $factory = $this->modules->get('TemplateEngineFactory'); $theme = $factory->load('author.tpl'); wire()->set('view', $theme); } }
elabx Posted November 11, 2020 Posted November 11, 2020 Hi! Does anyone know how to handle throwing a Wire404Exception so that PW renders the 404 page as it normally does? Getting: Fatal Error: Uncaught Wire404Exception I am using the Smarty Engine. Both the engine factory and smarty engines are on their latest versions. I am using url segments to change the url structure of the site I'm working on. Doing something like this: if($input->urlSegment1) { $pageOnSegment = getPageToRender(); $view->set('page', $page); } else{ throw new Wire404Exception(); }
gmclelland Posted November 11, 2020 Posted November 11, 2020 Hi elabx, On one of my sites, I have: if ($input->urlSegment1){ // unknown URL segment, send a 404 throw new Wire404Exception(); } and in another place I was using: // Don't let search engines index non-existing pages // see https://processwire.com/blog/posts/processwire-2.6.18-updates-pagination-and-seo/ // if(!count($paginated_calendar_postings) && $input->pageNum > 1) { if(!count($paginated_calendar_postings) && $input->pageNum > 1) { // I'm not sure why this line is needed, but it is // $session->redirect($pages->get($config->http404PageID)->httpurl()); throw new Wire404Exception(); } I think I used to have to do this, before a bug was fixed in this module? $session->redirect($pages->get($config->http404PageID)->httpurl()); Hope that helps
elabx Posted November 11, 2020 Posted November 11, 2020 Hi @gmclelland! I did found the issues you came across, but didn't solve them and also the redirect shouldn't happen before the 404 ? I read on this github issue that this shouldn't happen anymore in version 2 of the module so I went for updating everything but didn't work either still can't throw the exception on the controller.
gmclelland Posted November 11, 2020 Posted November 11, 2020 Hmm... I'm not sure then. Are you using TemplateEngineFactory with TemplateEngineTwig? Did you upgrade TemplateEngineTwig as well? Did you upgrade your Twig libraries with composer? Did you clear your site caches with Modules > Refresh? Just some thoughts... If I remember right..after upgrading to 2.x throw new Wire404Exception(); most of the time it would work, but one time it didn't. I just can't remember the use case. So maybe that bug isn't fully fixed? Perhaps you can provide Wanze your code so he can replicate and fix the problem?
elabx Posted November 11, 2020 Posted November 11, 2020 3 minutes ago, gmclelland said: Are you using TemplateEngineFactory with TemplateEngineTwig? I am using Smarty! For what I understand that shouldn't really matter, but I am not entirely sure.
dotnetic Posted March 17, 2021 Posted March 17, 2021 I am looking for an output strategy for repater fields or Repater Matrix fields (Pro fields) in my case. I would like to replicate the approach Ryan described in the blog post https://processwire.com/blog/posts/more-repeaters-repeater-matrix-and-new-field-rendering/ , but using Template Engine Factory (because I want to use Smarty or another template language). In short: Instead of a foreach loop that then uses many if clauses to distinguish the type, I would like to have a separate controller and template for each repeater matrix item. The controller should be used to modify the output before. Here is my working code, but I wonder if it might be better to use hooks like Template Engine Factory's hookBeforePageRender, or something else? //_init.php $factory = $this->modules->get('TemplateEngineFactory'); // check if the actual page has a modules_repeater (Repeater Matrix field) // and provide the output of the different modules as a variable if ($this->page->hasField('modules_repeater')) { // now get the output based on the type foreach ($this->page->modules_repeater as $module) { // Get the controller, to render a repeater item. $controller = $factory->controller("modules_controllers/{$module->type}.php", "modules/{$module->type}.tpl"); // You might pass some data via to the controller file, which you find at site/templates/modules_controller/nameOfTheRepeaterMatrixItem. // We assign the module repeater item to the $page variable so we can use it in our template and controller like this // $page->hero_headline $controller->page = $module; $controller->execute(); $output = $factory->render("modules/{$module->type}", ['page' => $module]); // Executing the controller renders the associated template via template engine. $this->view->set('modules_repeater', $output); } } Any suggestions? 1
benbyf Posted June 3, 2021 Posted June 3, 2021 HELLO! Trying to use Pug templating engine and have downloaded and installed both TemplateEngineBase and pug module, however pug itself seems to be missing as the module throughs an error saying Phug isn't found. How should I install pug itself??
da² Posted April 2, 2022 Posted April 2, 2022 (edited) It looks like there's a compatibility issue between modules TemplateEngineFactory and TemplateEngineTwig in current PW master and dev versions. I use the "Add Module From Directory" form: * With TemplateEngineFactory and it installs version 1.1.3 (no update available) * With TemplateEngineTwig, it chooses version 1.1.0 and reports a compatibility issue: Quote Requires TemplateEngineFactory 1.1.3 >= 2.0.0 So I can't install it. I'll try to install it from the sources but I did want to report that issue. Edited April 2, 2022 by da² 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now