Wanze
PW-Moderators-
Posts
1,116 -
Joined
-
Last visited
-
Days Won
10
Everything posted by Wanze
-
Your "controllers" aka regular ProcessWire templates are always in "site/templates", you can't customize this path. However, with this setting, you tell the module where your twig templates are, e.g. "views" in your case. Since you use twig, check out the template inheritance support from Twig, where you define a "global" template and other children-templates inherit stuff from it. If you enable this setting, you always have the same twig template behind the $view API variable. You either need to write this in an autoload module or attach the hook in your site/ready.php file. Learn more about hooks here: http://processwire.com/api/hooks/ Cheers
-
Hi, Sorry for my late answer, I was on vacation and traveling for the last 2 months The problem is the FileCompiler of ProcessWire trying to compile Twig stuff which should not be the case. I'll look into this. Can you disable the FileCompiler for all templates that are rendered with Twig? Cheers
-
@urz0r Not at the moment, how would you use this function with the module, can you make an example? As for now, you can hook after TemplateEngineSmarty::initSmarty() and customize the Smarty object, but I guess that is not useful in this situation. Cheers
-
@cappuccino You're welcome, I never saw this error before. What is the content of your ProcessWire PDF template (site/templates/pages2pdf/..) that is rendered by the module? Does it work if you you just put a "Hello World" in it? If so, you'd need to simplify your markup and debug what is causing the error. Cheers
-
Hi Henning, Interesting approach on how to use the module Looks like a caching problem to me, could you try to add $this->pdf = null after this line: https://github.com/wanze/Pages2Pdf/blob/master/Pages2Pdf.module#L218 The code should then look like the following snippet: [...] } else { $this->create($page, true); $name = $this->getPDFFilename($page); $this->wire('session')->message(sprintf($this->_("Pages2Pdf: Created PDF file(s) '%s'"), $name)); } // Add me! $this->pdf = null; } Cheers
-
@Gazley Did you add the dump extension via hook? http://twig.sensiolabs.org/doc/functions/dump.html Even if debug is active in twig, this function needs to be added additionally. Cheers
-
Hi Tony, Could you already solve this problem? It looks like this character is not included in the chosen font, maybe try another one? How did you output the degree symbol, hardcoded or with an entity, e.g. ° ? Cheers
-
Hi Gazley, Sorry I missed your post. Thanks for the suggestion, I'll add this to the next version so you are safe when you upgrade the module! Edit: Just saw that your post was pretty new haha Cheers
-
Sort problem: Selector with date needs empty dates last
Wanze replied to Xonox's topic in General Support
Hi Xonox, You could create a new PageArray and append the pages without the training start time at the end: $today = time(); $parent = $pages->get('/formacao/'); $trainings = $pages->find("parent=$parent, template=training, limit=6, !training_start<$today, sort=training_start"); $_trainings = new PageArray(); $empty = new PageArray(); foreach ($trainings as $training) { if ($training->training_start) { $_trainings->add($training); } else { $empty->add($training); } } $_trainings->import($empty); I'm sure there are more elegant solutions -
@adrian Wow you're fast, thanks for testing I hope it solves the problem! Btw I didn't know that you can pass a filename to Page::render(), so learned something new today (again) Cheers
-
Hi both, I don't know the module myself and I'm not sure why your prepended file is not respected when rendering via a filename. Can you try if this works? This should trigger the Page::render() of the search page and also output the markup from your corresponding smarty template. $event->return = $this->pages->get($this->searchPage)->render();
-
Updated the module to version 1.1.0 which adds the following features: Multiple data can be passed to the template engine via setArray() (alias: setMultiple()) The module now provides a second API variable $factory returning the singleton instance of the TemplateEngineFactory, which can be used to load partial views and chunks Chunks: Reusable code snippets that consist of a PHP file containing the logic and a template (view) to render the output (see https://github.com/wanze/TemplateEngineFactory#chunks) Thanks @justb3a for the contributions! Twig and Smarty modules were updated as well, shipping with the newest version of Twig/Smarty. I tested the module on the latest ProcessWire 2.7 and 3.x and everything worked fine. Let me know if you find any issues! Cheers
-
multilanguage Multilanguage without default language possible ?
Wanze replied to iNoize's topic in Multi-Language Support
Hi iNoize, The editing of multi-langauge fields can be restricted with permissions: https://processwire.com/api/user-access/permissions/#multi-language-page-edit-permissions Cheers -
You can hook after this method to further customize Smarty: https://github.com/wanze/TemplateEngineSmarty/blob/master/TemplateEngineSmarty.module#L130 Just ask if you need examples Cheers
-
I don't know Twig myself, but I think the problem is that the initTwig() method is called before you are registering your hook, so it is not executed. Is articles.php your template (controller)? Can you try the following: wire()->addHookAfter('TemplateEngineTwig::initTwig', function($event) { $twig = $event->arguments('twig'); $twig->addExtension(new Twig_Extensions_Extension_Text()); }); // Trigger initTwig again, just for testing $factory = $modules->get('TemplateEngineFactory'); $factory->load('articles', true); This is not nice, if it works, I have to think about other ways...
-
Your hook does not work for several reasons, try it like this: wire()->addHookAfter('TemplateEngineTwig::initTwig', function($event) { $twig = $event->arguments('twig'); $twig->addExtension(new Twig_Extensions_Extension_Text()); });
-
Hi a.masca Can you share your current code? Do you store the events inside ProcessWire or are they only available after submitting the form? Cheers
-
@suntrop Thanks! If you are using the inheritance feature of Twig, you shouldn't use a global template file, I think that might solve the problem. At the moment, twig always receives the "app.html" template. But what it needs is to receive the "home.tpl" template file. Twig then sees that this template is inheriting from "app.html" and does its magic Edit: Maybe this helps https://github.com/wanze/TemplateEngineSmarty#best-practices It's Smarty, but the template inheritance stuff seems to work the same way in various engines @szabesz Cool, nice tutorial! Thanks for sharing the link Cheers
-
Hi ottogal, Sorry for my late response. I currently don't have time to update Batcher, at least not for the next month. The module needs a rewrite because a lot changed since this was released, for example: Native support of ProcessWire's modal Make use of InputfieldSelector to build the selector strings ... I hope to update the module at the end of may, but since I don't know the release date of Pw 3 I can't promise... unless someone else takes over. Cheers
-
Glad it works! I'll check if this is an issue with my module or mPDF in general. The order of the includes doesn't matter, but you need to be careful not sending any output (headers) to the browser before downloading the PDF. For example echo out something, though in the context of ProcessWire all echos in your template are catched by PHPs output buffer, so you should be fine. You'd get warnings if that happens, something like "Headers already sent" Cheers
-
Hi Ryan, Strange, I've never seen this message before. Do you need to save the file or could you generate it dynamically when a download is requested? I'm thinking that maybe the combination of calling $pdf->save() first and then $pdf->download() afterwards has some issues. You could try these two approaches: 1) Save the PDF to the disk and let ProcessWire download it: $pdf->save($page->filesManager->path . $file_name); wireSendFile($page->filesManager->path . $file_name, array('forceDownload' => true)); You can also omit the forceDownload and see if it works. 2) Don't save the PDF to disk, always create it dynamically and download it: $pdf->download($file_name); Does any this work? Cheers
-
Hi RyanJ, I think the problem is that the module does not allow you to select the user template in the settings, am I right? Probably the simplest way would be to generate and store the PDFs by yourself with the module WirePDF. It's a wrapper around the mPDF library and included in the Pages2Pdf module. Check the examples here how to use the module, and please ask if you need further help in this. Cheers
-
Hi jmartsch, One solution would be to set your strings in the products.php template file and forward them to the view, for example: $view->set('strings', array( 'hello' => __('Hallo'), 'test'=> __('Test'), )); // ... products.tpl {$strings.hello} You could also organize all your translations in a single file and reference them via textdomain. Another possibility would be to register a smarty function which grabs your translation from a central file. Cheers
-
Hi cenatur78, Try to do the logic of building your menu in the "controller", not in the smarty template. Then you can pass the markup to the smarty template, e.g. $view->menu = $menu->render('testmenu'); Cheers
-
Hi 101Bram, Welcome to ProcessWire! So you somehow need to link one election page to one user account. Check out the Page field. On your user template, you can create a new Page field, let's name it "election". After creating the user and the corresponding election page, you can store the election page in this field. To create a link, you can simply use: $electionPage->url. Note that on your election template, you should check if the visiting user is equal to the user where the election page belongs to. If not, you can throw a 404 error. As always with ProcessWire, this is just one way of doing it Cheers