-
Posts
1,306 -
Joined
-
Last visited
-
Days Won
13
Everything posted by Juergen
-
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
-
Hello tpr, I have updated to PW 3.05 and the behaviour is gone. So the module works as expected ! Thanks for your efforts!
-
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?
-
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
-
I know! I have posted it also for the select: https://github.com/ryancramerdesign/ProcessWire/issues/1617
-
Thanks Mike Rockett. Issue is opened on Github (#1617). Best regards
-
Before I will open an issue I would like to know if only I had this issue or others too.
-
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
-
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.
-
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
-
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
- 100 replies
-
- 2
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
I dont know if this is a problem of the module or from PW in general. The path names on a multilingual site are only changed for the default language and not for the other languages. In my case I use parent title and date. In German (default) it shows me both, but in English I only get the parent title without the date. Best regards It is not a big problem because you can change the pathname afterwards via a hook for the other languages.
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
Hello @ all I want to share my code of a module which copies values from a parent page to a child page by using the add button of a pagetable field. If you find it useful you can copy the code or you can improve the code and post your ideas of improvement here. The intention for me was that I have pages with events and I dont want to write all the data for an event manually. Especially if only the date of the event is different. I use a pagetable field for the events and I want to click the add button of this field and a new childpage will be created with all the data of the event (title, description, summary,...) so I have only to fill in the start and end date for the event. So far so good, but it was a little bit tricky to get this to work with the add button of the pagetable field. So I decided to write a module which does the work for me. Here is the piece of code: <?php class CopyPageTableAdd extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Pagetable copy values', 'summary' => 'Copy Pagetable content by pressing the add button', 'href' => '', 'version' => 001, 'autoload' => true, 'singular' => true ); } public function ready() { $this->pages->addHookBefore('ProcessPageAdd::execute', $this, 'copyaddpage'); } public function copyaddpage() { //configuration $parenttemplatename = "events"; //the template name of the parent template $childtemplatename = "single-event"; //the template name of the newly created child template $page = new Page(); $page->parent = $this->input->get->parent_id; if ($page->parent->template == $parenttemplatename) {//check if it is the right parent template $page->template = $childtemplatename; //set the template for the created child page //copy all fields field values from the parent template (start) //enter all fields which you want to copy into the child page $page->title = $page->parent->title; $page->eventstatus = $page->parent->eventstatus; $page->eventtype = $page->parent->eventtype; $page->summary = $page->parent->summary; $page->headline = $page->parent->headline; $page->importanteventstext = $page->parent->importanteventstext; $page->importanteventstext = $page->parent->importanteventstext; $page->notifiable = $page->parent->notifiable; $page->reservationtype = $page->parent->reservationtype; $page->participantlimit = $page->parent->participantlimit; $page->participantmaxnumber = $page->parent->participantmaxnumber; $page->eventmaxstatus = $page->parent->eventmaxstatus; $page->eventcosttype = $page->parent->eventcosttype; $page->eventprice = $page->parent->eventprice; $page->eventpriceadd = $page->parent->eventpriceadd; $page->eventlocationname = $page->parent->eventlocationname; $page->street = $page->parent->street; $page->postalcode = $page->parent->postalcode; $page->eventlocationname = $page->parent->eventlocationname; $page->place = $page->parent->place; $page->region = $page->parent->region; $page->country = $page->parent->country; $page->googlemap = $page->parent->googlemap; //copy all fields field values from the parent template (end) $page->addStatus(Page::statusUnpublished); //this foreach loop is only if you have a multilanguage site to get the path names in each language //if your site is only single language you can use $page->name=$page->parent->name (but not tested) foreach ($this->languages as $lang) { $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $page->set("name$lang", $pageName); if ($lang->isDefault()) continue; $page->set("status$lang", 1);//activate the multilanguage checkbox } $page->save(); $this->session->redirect("../edit/?id=$page"); } } } The configuration part: //configuration $parenttemplatename = "events"; //the template name of the parent template $childtemplatename = "single-event"; //the template name of the newly created child template This is the part where you have to define the templates. The name of the parent template is responsible that the module only run on that template (in my case the template with the name "events). The name of the child template ist the template which should be created after pressing the add button (in my case the template with the name "single-event"). You have to fill in your template names. The module runs only if the parent template has the specific name and creates only child pages with the child pages template name. Copy all field values par: //copy all fields field values from the parent template (start) //enter all fields which you want to copy into the child page $page->title = $page->parent->title; $page->eventstatus = $page->parent->eventstatus; $page->eventtype = $page->parent->eventtype; $page->summary = $page->parent->summary; $page->headline = $page->parent->headline; $page->importanteventstext = $page->parent->importanteventstext; $page->importanteventstext = $page->parent->importanteventstext; $page->notifiable = $page->parent->notifiable; $page->reservationtype = $page->parent->reservationtype; $page->participantlimit = $page->parent->participantlimit; $page->participantmaxnumber = $page->parent->participantmaxnumber; $page->eventmaxstatus = $page->parent->eventmaxstatus; $page->eventcosttype = $page->parent->eventcosttype; $page->eventprice = $page->parent->eventprice; $page->eventpriceadd = $page->parent->eventpriceadd; $page->eventlocationname = $page->parent->eventlocationname; $page->street = $page->parent->street; $page->postalcode = $page->parent->postalcode; $page->eventlocationname = $page->parent->eventlocationname; $page->place = $page->parent->place; $page->region = $page->parent->region; $page->country = $page->parent->country; $page->googlemap = $page->parent->googlemap; //copy all fields field values from the parent template (end) This ist the part where you can fill in all fields which you want to copy the values. It copies the values from the parent page to the child page. You can do this also with a foreach loop, but I dont want to copy all field values so I write it manually for each field. The multilanguage part: foreach ($this->languages as $lang) { $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $page->set("name$lang", $pageName); if ($lang->isDefault()) continue; $page->set("status$lang", 1);//activate the multilanguage checkbox } The multilanguage part is necessary if you have a multilanguage site, because it creates the path names for each language in the right language. After that the multilanguage checkbox for the non default language should be checked to activate the page in this language. Here are some screenshots: 1) Press the add button of the pagetable field 2) A new child page will be created with prefilled values of the parent page 3) Path names are in the right language and multilanguage checkbox is activated So this might be useful for others Best regards
-
I have inserted the following code before the $k->save(); command: foreach($this->languages as $lang){ if($lang->isDefault()) continue; $k->set("status$lang", 1); $pageName = $page->title->getLanguageValue($lang); $k->set("name$lang", $pageName); } Now the multilanguage checkbox is activated and the multilanguage page names are in the correct language. Unfortunately the number of the page at the end of the language page name is different between German and English. The same childpage have the following page name for the URL: German: termine-im-februar-2 English: events-in-february-1 As you can see the number at the end is always one step lower in English than in German. It is not a really big problem, but if anyone has an explanation or a solution for this behaviour it would be great to post it here.
-
The above code from Mr. NiceGuy works quite well, but I have a multilanguage site so I need that the childpages have to be created in every language. At the moment they are only created for my default language. The problem is here: The alias is the same as in the default language and the "active" checkbox is not checked. How can I create childpages for all languages in this case? Best regards
-
New problem: comment form stops sending if email address for approval is in this syntax "id:fieldname". If I enter the email address for comment approval like 1006:mail ("1006" is the id of the page which contains the email field and "mail" is the name of the email field) no email will be sent. If I enter the email address as plain text like "myemail@abc.com" the email will be sent correctly. I have updated to the lates dev 2.7.3. The syntax above has worked in the past. Best regards EDIT: I have created a new comment field and now it works again
-
Problem solved: The cause of the problem was the wrong order of fields with dependencies in the template. Field B has a dependency of field A, but A was after B. I changed the field order from B, A to A, B and now it works.
-
Today I have discovered that my options fieldtype doesnt store any value. It had been working in the past as expected. I have updated to the latest dev version 2 days ago. If I want to select one or more options in that fieldtype the storage doesnt work anymore. It will be empty after pressing the save button. I use following options under the details tab: 1=user|persönlich 2=phone|telefonisch 3=envelope|per E-Mail 4=list-alt|per Anmeldeformular Does anyone has the same problem? Best regards
-
I have downloaded the latest version from Github today but the modal closes and saves after there are errors. In my case I have a field which is mandatory and the modal will be closed after pressing the save button and the field is empty. The fieldtype in this case is a options field with 4 checkboxes. One must be checked at least (required). In backend I get the error message that this field is required. Best regards
-
I changed the code a little bit. I dont use children in this case and now it works. <?php class AddCronJob extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Add Cron jobs for various functions.', 'version' => 100, 'summary' => 'Executing cron job tasks depending on time set', 'singular' => true, 'autoload' => true ); } public function init() { $this->addHook('LazyCron::every30Seconds', $this, 'ChangeOfferPages'); } public function ChangeOfferPages(HookEvent $e) { $seconds = $e->arguments[0]; $currentdatetime = time(); // Get timestamp for current date $pricelistpages = wire("pages")->find("template=productpricelistitem"); //get the page with the price template foreach ($pricelistpages as $pp) { $pp->setOutputFormatting(false); // without this we can't save the page later on $offerend = $pp->getunformatted(offerend); if ($offerend) { if (($pp->afterofferend == "1") AND ($offerend < $currentdatetime)) { $pp->pricetype = "1"; //set back price type to standard price $pp->offertprice = ""; //delete offerprice $pp->offerstart = ""; //delete offerdate start $pp->offerend = ""; //delete offerdate end $pp->save(); //save the price page } } } } }
-
I am also interested in this. I still haven`t found a solution `til now.
-
Question: How can I approve comments via email if the comments list is custom? Hello @ all, I use a custom code to show the comments in my own markup as described here (documentation of the comments). All works fine, but if a comment is approved via an email it doesnt change the status to approved. In the commentlist.php the following lines of code could be relevant. public function renderCheckActions() { $action = $this->wire('input')->get('comment_success'); if(empty($action) || $action === "1") return ''; if($action === '2' || $action === '3') { $message = $this->wire('session')->get('CommentApprovalMessage'); if($message) { $this->wire('session')->remove('CommentApprovalMessage'); $class = $action === '2' ? 'success' : 'error'; $commentID = (int) $this->wire('input')->get('comment_id'); $message = $this->wire('sanitizer')->entities($message); if($commentID) $message = str_replace($commentID, "<a href='#Comment$commentID'>$commentID</a>", $message); return "<p id='CommentApprovalMessage' class='$class'><strong>$message</strong></p>"; } } Does anyone have tried to make a custom comment list which works with email approval and how? Best regards
-
Problem solved: I deinstalled and reinstalled the comments and now it works. The problem was that the database was not updated, so comments rating could not be stored.