-
Posts
1,306 -
Joined
-
Last visited
-
Days Won
13
Everything posted by Juergen
-
Thanks Ryan, this works and solved may problem
-
Hello @ all, I have upgraded all my templates to use the namespace attribut introduced in PW 3. Therefore I have added "namespace Processwire" at the top of each template. In the backend I have disabled the loading of the compiler for each template. I works well, but I have problems loading modules in the templates. In my case I use AIOM to combine multiple files into one, but the syntax from the AIOM docs doesnt work anymore. The URL to the merged file cannot be created. I thougt that disabling compiler only for templates doesnt affect modules. Has anyone an idea to get it working again? Best regards Jürgen
-
I often use jsdelivr as free javascript CDN. They also offer the files for this slider on their CDN at https://www.jsdelivr.com/projects/flickity Only for those who are interested in. Advantage: you can combine multiple js files from this CDN into one - so only one request will be made Best regards
-
Also strange error on saving article in PW 3 (in this case PW 3.0.8): Parse Error: syntax error, unexpected '.' (line 39 of /home/.sites/......./site/modules/Pages2Pdf/mpdf/mpdf.php) Best regards Jürgen
-
ProcessSlider - Image sliders for ProcessWire
Juergen replied to mauricius's topic in Modules/Plugins
Edit to my last post: Slider works, but if the Images are inside in a repeater field it doesnt fetch the images. I dont know if this is a usual behavior or not. If the Image field ist standing alone it will work in PW 3.0.7. Best regards -
I have been learning PHP on my own, so I never vistit a PHP course or something like that. It was only "learning by doing". The only thing I have done was buying a book about PHP. I use it sometimes, but most of the time searching the web is enough. It always depends on what you try to achieve (outputting only content in frontend or creating complex modules with a lot of logic behind). For me the best way was to learn from examples. As Jonathan pointed out you dont need much PHP knowledge to output content on frontend.
-
ProcessSlider - Image sliders for ProcessWire
Juergen replied to mauricius's topic in Modules/Plugins
I use the latest PW (3.0.7) and unfortunately the slider doesnt fetch any images. I have tried it with 2 pages which have images, but no luck. Best regards -
Full Functional example of Send Form with attachment ?
Juergen replied to iNoize's topic in Getting Started
Maybe this could help - there are a lot of codes for forms. https://processwire.com/talk/topic/12010-front-end-tips-tools-and-general-development/?p=111633 Best regards -
Today I want to share a little module that adds 2 additional save buttons with redirect and 1 unpublish button to the page edit. 2 additional save buttons: My intention was that it would be nice if someone saves an article in the backend and will be redirected after saving directly to the frontend page of the article. This module adds 1additional save button at the bottom next to the default save button and 1 at the top. So you can choose if you want to save the article with the default save button or you will save it with the custom save button and you will get redirected to the frontend article. 1 unpublish button: The idea behind this was that I want to disable the setting tab for non superuser. The problem was if I hide it, then non superusers are no longer able to unpublish an article. Therefore this module adds an additional unpublish button at the bottom - the user clicks it and the page will be saved with status unpublished. All pages under the admin section will not be affected of this module. Module is multilingual, so you can set the button texts in all languages. Top view page status published: Bottom view page status published: Bottom view page status unpublished: Here is the code: <?php /** * Adding 2 additional save buttons with redirect to frontend and 1 unpublish button for page edit form. * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class CustomPageSaveAndUnpublish extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Custom page save and unpublish module', 'version' => 1, 'summary' => 'Example for adding 2 additional save buttons with redirect and 1 unpublish button to page edit', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { $this->addHookAfter("ProcessPageEdit::buildForm", $this, "addSaveButton"); $this->addHookAfter("ProcessPageEdit::buildForm", $this, "addUnpublishButton"); // tell processwire that this is a page save if ($this->input->post->submit_save_minor) { $this->input->post->submit_save = 1; // attach hook on page save $this->addHookAfter("Pages::saved", $this, "hookPageSave"); } if ($this->input->post->submit_unpublish) { $this->input->post->submit_save = 1; // attach hook on page save $this->addHookAfter("Pages::saveReady", $this, "hookPageSaveReadyUnpublish"); } } public function hookPageSave($event) { //function to redirect to the frontend after save $page = $event->arguments("page"); if ($this->input->post->submit_save_minor) { // this will get saved after this saveReady hook so no need to save here $pageid = $page->id; $goto = wire("pages")->get("id=$pageid")->url; //get url of frontend article wire("session")->redirect($goto); } } public function hookPageSaveReadyUnpublish($event) { //function to change the status to unpublished $page = $event->arguments("page"); $status = $page->status; $unpublishmessage = __("Status of the page is set to unpublished"); if ($this->input->post->submit_unpublish) { if ($status == 1) { $page->status = "2049"; $this->message($unpublishmessage); } } } public function addSaveButton($event) { //function to add the 2 additional save button with redirect at the top and at the bottom $page = $event->object->getPage(); $status = $page->status; if (($page->rootParent->id != "2") AND ($status == 1)) { //dont show on all pages which are under the admin section and which are not published $form = $event->return; $buttontext = __("Save and go to page"); // new submit button $f = $f2 = $this->modules->InputfieldSubmit; $f->attr("name", "submit_save_minor"); $f->attr("value", $buttontext); $f2->attr("name", "submit_save_minor"); $f2->attr("value", $buttontext); $f2->class .= ' ui-priority-secondary head_button_clone'; // add submit button after the regular save button only if page is published $form->insertAfter($f, $form->get("submit_save")); $form->insertAfter($f2, $form->get("submit_save")); } } public function addUnpublishButton($event) { //function to add the unpublish button at the bottom if page has status published $page = $event->object->getPage(); if ($page->rootParent->id != 2) { //dont show on all pages which are under the admin and dont show the button under the delete tab $form = $event->return; $unpublishbuttontext = __("Unpublish"); // new submit button $f = $this->modules->InputfieldSubmit; $f->attr("name", "submit_unpublish"); $f->attr("value", $unpublishbuttontext); // add unpublish button after the save button if ($page->status == 1) { $form->insertAfter($f, $form->get("submit_save")); } } } } Everybody who is interested can download the modul here: CustomPageSaveAndUnpublish.zip Best regards Jürgen
-
How to add additional button next to the save button on top (backend)
Juergen replied to Juergen's topic in General Support
Thanks BitPoet this does exactly what I wanted. Here is the complete code for all who are interested in: Edit: Condition not to show on pages under the admin section was added <?php /** * Adding other types of save buttons for page edit form. * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class CustomPageSave extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'CustomPageSave', 'version' => 1, 'summary' => 'Example for adding other save buttons to page edit', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { $this->addHookAfter("ProcessPageEdit::buildForm", $this, "addSaveButton"); // tell processwire that this is a page save if ($this->input->post->submit_save_minor) { $this->input->post->submit_save = 1; // attach hook on page save $this->addHookAfter("Pages::saved", $this, "hookPageSave"); } } public function hookPageSave($event) { $page = $event->arguments("page"); if ($this->input->post->submit_save_minor) { // this will get saved after this saveReady hook so no need to save here $message = __("Page was saved"); $this->message($message); $pageid = $page->id; $goto = wire("pages")->get("id=$pageid")->url; //get url of frontend article wire("session")->redirect($goto); } } public function addSaveButton($event) { $page = $event->object->getPage(); if ($page->rootParent->id != "2") { //dont show on all pages which are under the admin section $form = $event->return; $buttontext = __("Save and go to page"); // new submit button $f = $f2 = $this->modules->InputfieldSubmit; $f->attr("name", "submit_save_minor"); $f->attr("value", $buttontext); $f2->attr("name", "submit_save_minor"); $f2->attr("value", $buttontext); $f2->class .= ' ui-priority-secondary head_button_clone'; // add submit button after the regular save button $form->insertAfter($f, $form->get("submit_save")); $form->insertAfter($f2, $form->get("submit_save")); } } } -
Hello @ all, I have created a little module (adapted from Somas PageSave.module) which adds an additional save button next to the save button at the bottom. This button saves the page and redirects to the frontend page. Here ist the code: <?php /** * Adding other types of save buttons for page edit form. * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class CustomPageSave extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'CustomPageSave', 'version' => 1, 'summary' => 'Example for adding other save buttons to page edit', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { $this->addHookAfter("ProcessPageEdit::buildForm", $this, "addSaveButton"); // tell processwire that this is a page save if ($this->input->post->submit_save_minor) { $this->input->post->submit_save = 1; // attach hook on page save $this->addHookAfter("Pages::saved", $this, "hookPageSave"); } } public function hookPageSave($event) { $page = $event->arguments("page"); if ($this->input->post->submit_save_minor) { // this will get saved after this saveReady hook so no need to save here $message = __("Page was saved"); $this->message($message); $pageid = $page->id; $goto = wire("pages")->get("id=$pageid")->url; //get url of frontend article wire("session")->redirect($goto); } } public function addSaveButton($event) { $form = $event->return; $buttontext = __("Save and go to page"); // new submit button $f = $this->modules->InputfieldSubmit; $f->attr("name", "submit_save_minor"); $f->attr("value", $buttontext); // add submit button after the regular save button $form->insertAfter($f, $form->get("submit_save")); } } Now I want to do the same for the save button (copy) at the top, but I cannot figure out how. The problem is that both save buttons have the same name: submit_save. The code line for inserting the button is the following: $form->insertAfter($f, $form->get("submit_save")); But how can I achive this if the button at the top and at the bottom have the same name? Maybe someone can help me? Best regards
-
Module with cronjob to trash pages doesnt work
Juergen replied to Juergen's topic in General Support
What a silly mistake. This was the reason - now it works!!! Thanks Adrian -
Module with cronjob to trash pages doesnt work
Juergen replied to Juergen's topic in General Support
No luck with wire('pages') at the moment. I have triggered the page in front- and backend but the pages are still there. Maybe it has something to do that the pages are unpublished at the moment? -
Hello @ all, I have created a simple module which uses a cronjob to trash pages of certain templates after the end date. I think my code should be correct, but nothing happens. Here is my code: <?php class HookForEvents extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Cronjob to trash events', 'summary' => 'Add a cronjob to delete events', 'version' => 1, 'autoload' => true ); } public function init() { $this->addHook("LazyCron::everyMinute", $this, "trashevent"); } public function trashevent(HookEvent $e) { //put event pages to trash after the end date $eventpages = wire("pages")->find("template=single-event|events"); foreach ($eventpages as $eventpage) { $enddate = $eventpage->publish_until; $currenttime = time(); if ($enddate < $currenttime) { $pages->trash($eventpage); } } } } ?> The cronjob should only delete pages with the templates "events" or "single-event". The condition ist that the current time must be greater than the enddate (comparison). If the condition is true, then the page should be trashed. Maybe someone find a reason why this code doesnt work.
-
Strange error on PW 3.06, 3.07 and core Textarea field image settings
Juergen replied to Juergen's topic in General Support
Simple solution to this problem: By clicking the X-symbol (delete) on the right side the error message does not appear at the next login. Strange! I have tried this some time ago without success. -
Strange error on PW 3.06, 3.07 and core Textarea field image settings
Juergen replied to Juergen's topic in General Support
They are completely deleted, but it seems that the reference is still there. -
Since the update from 3.05 to 3.06 and now 3.07 I always get an error message in the backend. It always shows that the user does not have view access for these images, but the articles which are listed were deleted some time ago. I dont know why this message appears? Has anyone an idea why this happens? Best regards
-
Thanks Bit Poet, it does exactly what I want. Now I can filter comments depending on their star rating value. Issue is open at Github https://github.com/ryancramerdesign/ProcessWire/issues/1664
-
Hello GuroMeditation, your idea is really good, but in my case I have a filter form where the user can choose if all comments should be displayed or only comments rated with fe 5 stars. In this case it would be better to use a selector to find only comment pages which match the query. Best regards
-
Has anyone tried to output only comments with a specific rating value (fe all comments which are rated with 5 stars)? This is what I have tried, but I cannot get it to work. $selector = "page=$page, sort=-created, start=$start,stars=5";//show all comments which were rated with 5 stars $comments = FieldtypeComments::findComments("comments", $selector);//comments is the name of the field foreach($comments as $c){ echo $c->stars."<br />"; } All comments will be displayed instead of only comments with 5 stars. Has anyone an idea how to filter comments correctly in this way? Best regards Jürgen
-
Yes Yes everything is up to date. I have updated it manually. I will check if the same issue happens during the next update. Thanks for your help
-
Today I have tried to update from 3.05 to 3.06 but I always get the following error message in the backend. Unable to locate ZIP: /home/......../web/site/assets/cache/ProcessWireUpgrade/devns.zip 17 secs Is updating PW from the backend in version 3 not possible at the moment? Best regards Jürgen
-
This is how I got it working: Use this code in the template include("./includes/Customcommentform.php"); $form = new Customcommentform($page, $page->comments); echo $form->render(); Remove "namespace ProcessWire;" at the top of the file Use the template compiler. The reason was that the commentform.php was the only include file in the template which has the namespace commmand at the top. All the others dont have it at the top. By removing the namespace attribute the compiler works. Otherwise you will get an error message. Hope this helps other who are struggeling with the same problem. @BitPoet: You were right with your idea, but changing the settings in the template file doesnt work in this case, because you can change it only for all files in the template. In this special case it was necessary to adapt the commentform.php alone.
-
I found the solution: in the template file use the following code: include("./inc/CustomCommentForm.php"); $form = new CommentForm($page, $page->comments);//HERE YOU HAVE TO USE THE DEFAULT CLASS COMMENTFORM INSTEAD OF CUSTOMCOMMENTFORM!!!! echo $form->render(); Now it works! Sorry but this doesnt work - it loads the default comment form
-
No this doesn´t work - independed of which setting is choosen. No usage of compiled file leads to error 500. On the frontend the following error message will be displayed: Error: Class 'Customcommentform' not found (line 263 of /home/.sites/24/......./products.php)