Jump to content

Juergen

Members
  • Posts

    1,419
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Juergen

  1. 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?
  2. 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.
  3. 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.
  4. They are completely deleted, but it seems that the reference is still there.
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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.
  12. 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
  13. 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)
  14. In PW version 3.05 the following code doesnt work anymore to make a custom comment form. require("./includes/Customcommentform.php"); $form = new Customcommentform($page, $page->comments); echo $form->render(); Is there another way to make this working again? Maybe it has something to do with the namespace. Best regards
  15. Hello tpr, I have updated to PW 3.05 and the behaviour is gone. So the module works as expected ! Thanks for your efforts!
  16. Hello @ all, I read Somas solution how to remove the add button and I have tried to adapt the code for another condition. Soma uses the number of rows as his condition but I want to use the value of a field instead, but I can get it to work. In my case I want to use a fieldtype option (select) in the page template to remove the add button or not. If option "1" is selected the button should be removed - if option "2" is selected the button should be still there. Here is what I have tried: public function renderPageTable(HookEvent $event){ // get the table field $table = $event->object; $page = $event->arguments[0]; // make sure this is our field if($table->name !== "singleeventtable") return; // rendered by InputfieldButton::render if($page->eventkindchooser == "1") { $this->buttonHook = $this->addHookAfter("InputfieldButton::render", null, function(HookEvent $event){ // overwrite/remove button markup $event->return = ''; }); } } Eventkindchooser is the name of the option fieldtype. Can anyone point me into the right direction?
  17. Hello @ all, I want to know if anybody has the same problem with image fields: clicking on the image variations leads to "process returns no content". If others have this problem too I would open an issue on Github. Best regards PW version: 3.0.5
  18. Hello Matjzap, thanks for your solution. It works for both, the slider and the select. I have posted your solution on Github. Maybe it will be corrected after the next update. Best regards
  19. I know! I have posted it also for the select: https://github.com/ryancramerdesign/ProcessWire/issues/1617
  20. Thanks Mike Rockett. Issue is opened on Github (#1617). Best regards
  21. Before I will open an issue I would like to know if only I had this issue or others too.
  22. Hello @ all, yesterday I have upgraded to the latest devn 3.05 and now I have a problem with my datetime inputfields. The problem is that the slider always shows time from 1-12 hours instead of 1-24 hours per day. I have set H:i format for the input. Does anybody know where the problem could be. Best regards Jürgen
  23. For the moment the hook adds the field description as a title attribut to the form input element (f.e a textfield). By hovering of the input field the field description will be shown as the tooltip. But I want to show the tooltip by hovering over the label of the input element instead of the input field.
  24. I use the following code from above to show tooltipps if I hover over an input field. <?php class InputfieldHookAddTitle extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Inputfield Hook Add Title', 'version' => 100, 'summary' => 'Adds title attribute to inputfields with field description as value', 'singular' => true, 'autoload' => true, ); } public function init() { $this->addHookBefore('Inputfield::render', $this, 'addTitle'); $this->addHookBefore('InputfieldForm::render', $this, 'modifyMarkup'); } public function addTitle(HookEvent $event) { $inputfield = $event->object; if ($inputfield->description == "") return; $inputfield->setAttribute('title', $inputfield->description); $event->return; } public function modifyMarkup($event){ $form = $event->object; $modifiedMarkupArray = array( 'list' => "\n<ul {attrs}>\n{out}\n</ul>\n", 'item' => "\n\t<li {attrs}>\n{out}\n\t</li>", 'item_label' => "\n\t\t<label class='InputfieldHeader ui-widget-header{class}' for='{for}'>{out}</label>", 'item_label_hidden' => "\n\t\t<label class='InputfieldHeader InputfieldHeaderHidden ui-widget-header{class}'><span>{out}</span></label>", 'item_content' => "\n\t\t<div class='InputfieldContent ui-widget-content{class}'>\n{out}\n\t\t</div>", 'item_error' => "\n<p class='InputfieldError ui-state-error'><i class='fa fa-fw fa-flash'></i><span>{out}</span></p>", 'item_description' => "", 'item_head' => "\n<h2>{out}</h2>", 'item_notes' => "\n<p class='notes'>{out}</p>", 'item_icon' => "<i class='fa fa-{name}'></i> ", 'item_toggle' => "<i class='toggle-icon fa fa-angle-down' data-to='fa-angle-down fa-angle-right'></i>", // ALSO: // InputfieldAnything => array( any of the properties above to override on a per-Inputifeld basis) ); $form->setMarkup($modifiedMarkupArray); } } It works quite well, but I would prefer to show the tooltipps by hovering over the label instead of the inputfield. Is that possible and how? Best regards
  25. You can do it in the module. Here is the code of an module which changes the path names for multilingual site. <?php /** * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class CorrectPagenames extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'CorrectPagenames', 'version' => 1, 'summary' => 'Output custom path names multilingual', 'singular' => true, // Limit the module to a single instance 'autoload' => true // Load the module with every call to ProcessWire ); } public function init() { // init() is called when the module is loaded. // saveReady is a hook after processing the previous changes of the page, // but just before those changes are saved to the database. // It's called for each page that's being saved, no matter if it's in // the backend or in your templates via the api. $this->addHookBefore('Pages::saveReady', $this, 'beforeSaveReady'); } public function beforeSaveReady($event) { $page = $event->arguments[0]; //create custom path name for children events $datestart = $page->publish_from; // I use the publish from date for the path name $datestart = date('Y-m-d', $datestart); $eventtitle = $page->parent->title; // I also use the parent title for the path name $page->name = $eventtitle . '-' . $datestart; //putting it all together for the default language foreach ($this->languages as $lang) { //multilanguage starts here if ($lang->isDefault()) continue; $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $pageName = $pageName . '-' . $datestart;// create custom path for other languages $pagelanguage = "name" . $lang; $page->$pagelanguage = $pageName; //this sets the path name for each language } } } You can take a look on how to achive it (as an inspiration ) Best regards
×
×
  • Create New...