Jump to content

Juergen

Members
  • Posts

    1,394
  • Joined

  • Last visited

  • Days Won

    17

Everything posted by Juergen

  1. Hello @ all, I have created a product page where customers can filter products depending on various attributes. I dont want to show all product matches on one page so I use a pagination to split it. So far so good - everything works as expected. The problem starts when I press the pagination button to see the next page (fe page 2). Then all products will be shown instead of the selected ones. As you can see: The pagination shows all pages Here are some code examples: // Get all products matching the filter criteria $p = $pages->find("template=products$productkindselect$offerkindselect, limit=$itemnumber"); $resultcounter = count($p); if ($resultcounter > 0) { //loop through each item foreach ($p as $child) { //Output the children fe $child->title; } } The code for the pagination $results = $p; echo $results->renderPager(array( 'currentItemClass' => "active", 'nextItemLabel' => "<span class='fa fa-angle-double-right'></span>", 'previousItemLabel' => "<span class='fa fa-angle-double-left'></span>", 'listMarkup' => "<nav><ul class='pagination'>{out}</ul></nav>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>" )); $pagination = $results->renderPager(); Has anyone tried to use a pagination with a filter an has a working solution? best regards
  2. Hello szabesz, thanks for your reply. Yes there is a singleimage.php inside the products folder (without any writing mistakes). Thats the reason why I cannot find an explanation why it doesnt work. You write in your case it works well, so the problem is somewhere on my side.
  3. Sorry but this makes no difference
  4. Hello @ all, I want to create a new render instance of an image field like described in this post https://processwire.com/blog/posts/processwire-3.0.7-expands-field-rendering-page-path-history-and-more/#specifying-custom-views I created the fields folder as described. Everything works fine if the render file is dirctly under the field folder, but if I want to use a custom rendering file it doesnt grab it. I have created a subfolder inside the fields folder which was named "products". In it I have a custom image file for a product image. The image field name is "singleimage" and the file inside the products folder is "singleimage.php". I have tried to render the image output in this way: echo $page->render('singleimage', '/products/singleimage'); Unfortunately it doesnt grab the file "singleimage" inside the "products" folder. It always uses the fallback. What can be the reason? Is the syntax wrong? I use the latest dev version of PW Best regards
  5. After updating to 3.2.3 I get the an error 500 and cannot login to backend. Debugging shows the following error message: Cannot redeclare class AIOM (line 1021 of /home/.sites/......../web/site/modules/AllInOneMinify/AllInOneMinify.module) This is the code on line 1021: class AIOM extends AllInOneMinify {} Edit: Solved! I had 2 instances of AIOM with different file names so the class was 2 times declared. Now it works!!
  6. Thats not the problem, my configuration is correct: $config->timezone = 'Europe/Vienna', also on the ini. I guess that if the pagetable gets the data from an json file (I havent looked at it yet) and the file is not UTF-8 and there are special characters in it, it will output an empty string. I had this problem also on a json file on the frontend. After outputting it in UTF-8 all content was displayed properly on the frontend.
  7. It has definitely to do with the strftime format. If I use the standard format (fe. d-F-Y) it works. Question: On the frontend template I have included setlocale to output the correct strftime-format. Will be setlocale automatically included in the admin template or do I have to include it manually? I use the Reno theme. Best regards
  8. @BitPoet, yes, the "%e" could not be the cause because I can output the date on frontend without any problems. It only seems that the pagetable field could not output a date in this format.
  9. Hello Horst, There are no external php files involved and I am sure that PW core files are in UTF-8. DB tables should also be in UTF-8. The date is stored in the db in this format: 2016-03-01 14:00:00 The possible cause could be my output formatting: I use PHP strftime to format my date/time output. Maybe this causes the behaviour but it should not be a problem. Best regards
  10. Hello @ all, today I have discovered a strange behavior of outputting German Umlauts in a pagetable field. In my case I want to output the start date with the Geman month name (in this scenarion "März" which means March in English). März includes a special German character called "Umlaut" which will not be outputted. Take a look at the screenshots: 1) German As you can see all dates which include the month "März" (=March) will not be displayed in the pagetable field. März includes the special character "ä" and therefore it will not be outputted 2) English The same in English - all dates will be displayed properly. Has someone discovered the same behavior. It seems that the charset is not UTF-8. Best regards Jürgen
  11. Now I got it working ! I check again the username in this case, therefore I grab the username at the beginning of this code. $usernamevalue = $sanitizer->username($input->post->user);//grab the username after submit $database = $this->wire('database'); $name = $usernamevalue; $query = $database->prepare("SELECT attempts FROM session_login_throttle WHERE name=:name"); $query->bindValue(":name", $name); $query->execute(); $numRows = $query->rowCount(); if ($numRows) list($attempts) = $query->fetch(PDO::FETCH_NUM); echo $attempts;//this outputs the login attempts Hope this helps others with the same problem.
  12. Hello @ all, on my frontend form I use a login throttle with "try" and "catch" and it works well. What I want is to add a counter of the failed login attempts displayed for the user, so the user can always see how many login attempts were done. Example: Login attempt 1, 2, 3 and so on. How can I count the number of attempts and output it on the frontend (nothing to store in the database). Has anyone done something similar in the past and can help me? Best regards
  13. Thanks Ryan, this works and solved may problem
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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.
  19. 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
  20. 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
  21. 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
  22. 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")); } } }
  23. 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
  24. What a silly mistake. This was the reason - now it works!!! Thanks Adrian
×
×
  • Create New...