Wanze
PW-Moderators-
Posts
1,116 -
Joined
-
Last visited
-
Days Won
10
Everything posted by Wanze
-
Cache entire page except some part of it? Approaches?
Wanze replied to Aleksey Popov's topic in General Support
@Jan Romero Looks good, but when you enable template caching it will cache the output and therefore show the same image again. Unless you configure the cache to ignore caching when using the GET variable, but in this case there is no caching at all Edit: Sorry didn't look carefully @Aleksey Popov I guess you're after a solution some other template engines are offering where you specify a sction like this: {nocache} Hey, I'm dynamic {/nocache} As far as I know, there is no solution out of the box. Use the techniques from Soma or Reno. A module to build something like this in ProcessWire would be easy, but you wouldn't gain any performance compared to the other solutions. Cheers -
H Isag, In the template files inside /site/templates/pages2pdf you put the markup that is rendered in the PDF file. It's like a "normal" ProcessWire template. The $page->body does not output the content of the body tag. It outputs the value of a field called "body". This is just an example, you can output other fields and use the ProcessWire API to build your output. Cheers
-
Hi Maverick, How do you handle validation, if there are errors in the forms (e.g. empty required field) ? You could move the code form your "contact-form.php" into the same template that is rendering the form, or simply include this file when the form was submitted. If the form data is valid, process the data with your working code. If the data is not valid or the form was not submitted, display the form as usual. Once your code is implemented in a template, you can can optionally use a module to send the mails, but if everything works - why change a running system? Cheers
- 3 replies
-
- contact from
- smtp
-
(and 1 more)
Tagged with:
-
Assuming I'm understanding the question: You can set a flag, for example on your page object. In the main template, don't render anything if the flag is set.
-
Thanks Nico, will integrate your suggestions in the next version
-
Hi Sevarf2, Sorry for my late response...! Just "main" or "main.tpl" if you've set "tpl" as the extension. What is the content of your main.tpl? You should see this content rendered by the selected engine. This option is useful if your controllers (aka Pw-Templates) all render the same markup. With this option, you'd define this markup in your "main.tpl" file, and home.php would render it. If you don't use the global template file, home.php would render "home.tpl". Does it make sense? Cheers
-
ProcessDatabaseBackups results in 'Login failed'
Wanze replied to BFD Calendar's topic in Modules/Plugins
Check the entry $config->userAuthSalt in your site/config.php file. This hash must be identical with the one on your live site. -
Hi Isag, The WirePDF module is included in Pages2Pdf, you should find it in your modules list. After installing "WirePDF", you should be able to install "Pages2Pdf"... I'm not sure why this is not working out of the box, I thought that ProcessWire would install the dependencies automatically, if available. What version of Pw are you running? Cheers
-
$image->description returns an empty string for guest users
Wanze replied to hettiger's topic in General Support
Hi hettiger, Welcome to ProcessWire! Do you have template cache enabled or using MarkupCache by any chance? If it's a multilang site: Does the guest user maybe have a language where the image description isn't filled/translated? Cheers- 3 replies
-
- 2
-
- image
- description
- (and 5 more)
-
How to Iterate Through All Fields of a Repeater?
Wanze replied to bytesource's topic in API & Templates
Hi Stefan, The repeater field is PageArray holding pages. I'm not sure if a repeater can contain another repeater, if it's possible this wouldn't be a good idea in my opinion Extract your logic into a function that can be called recursive, this is just an example written in the browser, not tested: function setLanguageValue(Page $p, $language) { $pageFields = $p->fields; // iterate through all fields of the given page foreach ($pageFields as $field) { $type = $field->type; // only select a field if it is translatable if ($type == "FieldtypeTextLanguage" || $type == "FieldtypeTextareaLanguage") { $p->setLanguageValue($language, $field->name, "some dummy text"); } elseif ($type == "FieldtypeRepeater") { // Go recursive here $repeaterFieldName = $field->name; foreach ($p->$repeaterFieldName as $subpage) { setLanguageValue($subpage, $language); } } } $p->save(); } // Execute it $startPage = wire('pages')->get("/"); $russian = wire('languages')->get("ru"); setLanguageValue($startPage, $russian); -
Hi peterfoeng, What is the content of your _Ajax.php file? Does it work if you do echo ou the template and the exit if you do not have to process any additional logic? if ($config->ajax) { $view = $factory->load('custom-templates/_Ajax.php', true); echo $view->render(); exit; } Cheers
-
All the best almighty Ryan
-
@everfreecreative You may want to check out my module: http://modules.processwire.com/modules/template-engine-factory/ It basically is a wrapper around the "internal ProcessWire template engine" with the option to add Smarty or Twig as external engines. The basic idea is that your regular template files are controllers which delegate the output to a corresponding template file. If you need MVC in ProcessWire, this module can help you. *Advertisment mode off* Cheers
- 206 replies
-
- 1
-
- standarisation
- templates
-
(and 1 more)
Tagged with:
-
This won't work, because in the static method getModuleInfo() there is no guarantee that the API is already available. See: https://github.com/wanze/ProcessBatcher/issues/1 Cheers
-
Noob question: Problem with page field used as link
Wanze replied to manlio's topic in Getting Started
If you'd choose "Single page (Page) or empty page (NullPage) when none selected" in your pagereference field, then the error wouldn't happen. However, maybe you should modify your snippet to check if there is a page selected before outputting the url -
Presenting A Set of Images From Another Page For Selection
Wanze replied to sharpenator's topic in General Support
Hi sharpenator, Looks like this module from Soma could help you out: http://modules.processwire.com/modules/page-list-image-label/ You could use it to render the icon image of your "format pages" Cheers -
Noob question: Problem with page field used as link
Wanze replied to manlio's topic in Getting Started
This sounds strange. What do you get when outputting var_dump($menu->pagereference);die(); Should be a Page object with lots of information... what does it say in your case? -
Hard to tell Did you echo out $_POST or checked the request with DevTools/Firebug if there are really no values sent? Often this happens because people forget to add a trailing slash to ProcessWire urls in the form action. In this case, Pw does a redirect and you loose post variables. One thing you could try is changing: action="./" to action="<?= $page->url ?>" although I'm pretty sure it's not the issue...
-
Understanding FieldtypeTextareaLanguage::wakeupValue
Wanze replied to bytesource's topic in Module/Plugin Development
Hi, Your module is not autoloaded - it does not get executed automatically by ProcessWire in each request. Try adding autoload=true to your getModuleInfo method. Cheers (also Stefan ) -
I can also suggest you cyon.ch. Hosting several sites there - the control panel and support is awesome!
-
I'd go with a PDF library like mpdf or tcpdf which create your files serverside - they all are similair (depending on the same basic library called fpdf). If you can create your invoice in HTML, you should try the mpdf library, simply because the support of converting HTML/CSS to a PDF file is really nice. If you install my Pages2Pdf module, you have a separate module called WirePDF that is a wrapper around the mpdf library, optimized for ProcessWire. Here is a readme how you could use the module to save/download a PDF file from HTML markup or a ProcessWire template: https://github.com/wanze/Pages2Pdf#wirepdf
-
Hi, im on mobile sorry for short answers. 1) not sure why it happens. You could try to update the module. The new pdf engine behind has better html and css support. You'd need to separate your css into a separate css file thought, see instructions on one of my earlier posts. 2) setting the cache time to zero will always generate a new pdf file. Cheers
-
Hi nfil, I'm not sure, what's the issue? Is it the image that is not working? If it is not related to mpdf, try to put your code in a "normal" Pw template under /site/templates/ and check if it works there. When everything's correct, this module should render the same output. If there are differences, that is due to limited HTML/CSS support, but the images should work. The first code example contains some errors, for example you can't write this: $count = "count()>1"; // $visavalue_b is populated now check if it is greater than 500000 if ($visavalue_b->($count)>=500000) { The second example contains no image output? Sorry I don't have time to debug, I'm away some weeks from tomorrow and I need to pack all my stuff If you have questions to general stuff Pw or PHP related, I'm sure other members can help you in this awesome forum somwhere. Cheers
-
Thanks Today I pushed a little update (v.1.0.2) with some improvments. If you update to this version and already installed/used Smarty or Twig, make sure to update those modules as well. What's new? When loading a template file with the factory, you can optionally tell the module to use the given file behind the API variable: $factory = $modules->get('TemplateEngineFactory'); $view = $factory->load('pw_rocks', true); Setting the second parameter to true, the template file 'pw_rocks' is now used as active template behind the API variable. In the example above, the template file is also assigned to '$view' which reflects this change also to the $view variable which is locally scoped in controllers. Whatever template is set behind the $view variable is used by the module when rendering the output of a page.
-
Thanks! If the HTML markup is the same, maybe you could solve it with loading different CSS files. If markup is different, you'd need to dynamically set the template that is behind the API variable ($view or your custom name). Something like this, not tested: $theme_template = isDay() ? 'day' : 'night'; $theme = $factory->load($theme_template); // Load the correct theme wire()->set('view', $theme); // Set the context of view variable to be the correct theme template $view = wire('view'); // Reassign to locally scoped $view variable - not sure if this is necessary, but could be This must happen before you pass any variables to $view. If you need this check on the whole site, you could also use ProcessWire's prependTemplateFile option and put this code in your prepended template file (controller).