Jump to content

Juergen

Members
  • Posts

    1,348
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by Juergen

  1. Hi @bernhard I want to make the colheaders multilingual. Is ther a way to achive this in simple way or is it necessary to change the default textarea into a multilingual textarea? Best regards
  2. With this little tutorial I want to show you how you can change the text of the add new button inside the children tab. This is the default button text which will be rendered on every template where children are allowed: And this is how it look likes after the manipulation: So it is a little bit customized. Maybe you can make it also with JS but I show you a way to change it via a hook inside the ready.php. Copy and adapt the following code into your ready.php. $pages->addHook('ProcessPageEdit::buildForm', function($event) { $page = $this->pages->get($this->input->get->id); $template = $this->pages->get($this->input->get->id)->template; //run the code only on the following templates -> adapt it to your needs if(($template == "event_events") || ($template == "event_dates") || ($template == "event_businessvacations") || ($template == "event_specialbusinesshours")) { $form = $event->return; $field = $event->object; $href = $this->config->urls->admin.'page/add/?parent_id='.$page; $field = $this->modules->get('InputfieldButton'); $field->attr('id+name', 'add_event'); $field->attr('class', $field->class); $field->attr('value', 'Add new event'); $field->attr('href',$href); $field->attr('icon','plus-circle'); $form->insertAfter($field, $form->get("AddPageBtn")); $form->remove($form->get("AddPageBtn")); } }); You can use the code as it is, but you have to adapt the if conditions to run it only on the templates you want. In my case I run it on 4 different templates. You can also change the icon if you want. Hope this will be helpful for some of you!
  3. Hello @ all, I have a template select in my calendar template, where the user can choose if the new created page should use the template of a company vacation, special opening hours, an event or a default date. It is the template select which will be taken before a new child page will be created. Most of the time the user didnt take care of this select function and creates a page with the pre-selected template. After creating the page the user recognizes, that this is the wrong template and he has to delete the newly created page before creating a new child page with the correct template. My question: Is it possible, fe via a hook, to add a "select template" option at the top of this select, so that the user has to select the correct template first? Otherwise he will get an error. This would be a real enhancement to the workflow. Best regards
  4. Very useful if you want to create automatic breadcrumbs via a function. I had this problem by creating child pages under a parent that should not be displayed via a real URL. The parent was only to categorize the content. But in the breadcrumbs it was displayed. In my case I solved it by categorize the children via different templates, but if you have only one template for the children, this solution will not work any longer.
  5. For all of you who do not want to install a module: I have written a code snippet which could be copied into the ready.php. But first of all you have to include the Simple HTML dom parser to your project - I recommend to install it via composer. This is important because the manipulation of the markup depends on this library. I use the manipulations only on my "body" field, so therefore I wrote if($page->template->hasField('body')){ but you can change the name of the field according to your needs. So here we go: Copy this code into your ready.php /** * UIkit Textformatter for body field * * Changes various HTML elements to UIKit markup elements in the body field * * Tables * Unordered lists * Unordered list items * Ordered lists * Tooltips on links * Blockquotes */ if($page->template->hasField('body')){ $bodydom = HtmlDomParser::str_get_html($page->body); if (!empty($bodydom)) { //tables $tables = $bodydom->find('table'); foreach($tables as $table){ $table->style = null; $table->cellspacing = null; $table->cellpadding = null; $table->border = null; if($table->class){ $table->class = 'uk-table '.$table->class; } else { $table->class = 'uk-table'; } } //unordered lists $ulists = $bodydom->find('ul'); foreach($ulists as $list){ if($list->class){ $list->class = 'contentlist uk-list uk-list-space '.$list->class; } else { $list->class = 'contentlist uk-list uk-list-space'; } } //unordered list items foreach($bodydom->find('ul li') as $li){ $li->innertext = $li->innertext; } //ordered lists $olists = $bodydom->find('ol'); foreach($olists as $list){ if($list->class){ $list->class = 'custom-counter '.$list->class; } else { $list->class = 'custom-counter'; } } //textlinks $anchors = $bodydom->find('a'); foreach($anchors as $a){ if(!empty(strip_tags($a->innertext))){ $a->class = "textlink"; $a->{'data-uk-tooltip'} = ''; } } //blockquotes $blockquotes = $bodydom->find('blockquote'); foreach($blockquotes as $b){ $b->innertext = '<i class="fa fa-quote-left fa-2x uk-align-left"></i>'.$b->innertext; } //Manipulating figcaption with uikit css class foreach (($bodydom->find('figcaption')) as $caption) { $caption->class = 'uk-thumbnail-caption'; //add class to figure caption tag } foreach (($bodydom->find('img')) as $img) { //manipulate image links with tooltip and lightbox attributes if ($img->parent->tag == 'a') { $pageId = (int) wire($this->page)->get('id'); //get current page id for lightbox group $img->parent->{'data-uk-tooltip'} = ''; //add tooltip attribute $img->parent->{'data-uk-lightbox'} = '{group:\'' . $pageId . '\'}'; //add lightbox attribute if ($img->alt) { $img->parent->title = $img->alt; //add alt attribute as anchor title } else { $img->parent->title = __("Lightbox view of the image"); //add default anchor title } } //create case types if (($img->parent->tag != 'a') && ($img->parent->tag != 'figure')) { $case = 'img'; } if (($img->parent->tag == 'a') && ($img->parent->parent->tag != 'figure')) { $case = "a img"; } if ($img->parent->tag == 'figure') { $case = "figure img"; } if (($img->parent->tag == 'a') && ($img->parent->parent->tag == 'figure')) { $case = "figure a img"; } switch ($case) { case 'img': //create space before image class if ($img->class) { $img->class = ' ' . $img->class; } $img->class = 'uk-thumbnail' . $img->class; if (strpos($img->class, 'align_left') !== false) { $img->class = str_replace('align_left', 'uk-align-left', $img->class); } elseif (strpos($img->class, 'align_right') !== false) { $img->class = str_replace('align_right', 'uk-align-right', $img->class); } elseif (strpos($img->class, 'align_center') !== false) { $img->class = str_replace('align_center', 'uk-align-center uk-text-center', $img->class); } else { $img->class = $img->class . ' no-align'; $img->outertext = '<span class="uk-display-block uk-margin-bottom">' . $img->outertext . '</span>'; } break; case 'a img': $img->parent->class = 'uk-thumbnail ' . $img->class; if (strpos($img->class, 'align_left') !== false) { $img->parent->class = str_replace('align_left', 'uk-align-left', $img->parent->class); $img->outertext = '<span class="uk-overlay uk-overlay-hover">' . $img->outertext . '<span class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></span></span>'; } elseif (strpos($img->class, 'align_right') !== false) { $img->parent->class = str_replace('align_right', 'uk-align-right', $img->parent->class); $img->outertext = '<span class="uk-overlay uk-overlay-hover">' . $img->outertext . '<span class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></span></span>'; } elseif (strpos($img->class, 'align_center') !== false) { $img->parent->class = str_replace('align_center', 'uk-align-center uk-display-inline-block', $img->parent->class); $img->outertext = '<span class="uk-overlay uk-overlay-hover">' . $img->outertext . '<span class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></span></span>'; $img->parent->outertext = '<span class="uk-display-block uk-text-center test">' . $img->parent->outertext . '</span>'; } else { $img->parent->class = $img->class . ' no-align uk-thumbnail'; $img->outertext = '<span class="uk-overlay uk-overlay-hover">' . $img->outertext . '<span class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></span></span>'; $img->parent->outertext = '<span class="uk-display-block uk-margin-bottom">' . $img->parent->outertext . '</span>'; } $img->class = null; break; case 'figure img': if (strpos($img->parent->class, 'align_left') !== false) { $img->parent->class = str_replace('align_left', 'uk-align-left', $img->parent->class); } elseif (strpos($img->parent->class, 'align_right') !== false) { $img->parent->class = str_replace('align_right', 'uk-align-right', $img->parent->class); } elseif (strpos($img->parent->class, 'align_center') !== false) { $img->parent->class = str_replace('align_center', 'uk-align-center uk-text-center', $img->parent->class); } else { $img->parent->class = 'uk-display-inline-block no-align'; } $img->class = 'uk-thumbnail'; break; case 'figure a img': if (strpos($img->parent->parent->class, 'align_left') !== false) { $img->parent->parent->class = str_replace('align_left', 'uk-align-left', $img->parent->parent->class); $img->outertext = '<div class="uk-overlay uk-overlay-hover">' . $img->outertext . '<div class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></div></div>'; } elseif (strpos($img->parent->parent->class, 'align_right') !== false) { $img->parent->parent->class = str_replace('align_right', 'uk-align-right', $img->parent->parent->class); $img->outertext = '<div class="uk-overlay uk-overlay-hover">' . $img->outertext . '<div class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></div></div>'; } elseif (strpos($img->parent->parent->class, 'align_center') !== false) { $img->parent->parent->class = str_replace('align_center', 'uk-align-center uk-text-center', $img->parent->parent->class); $img->outertext = '<div class="uk-overlay uk-overlay-hover">' . $img->outertext . '<div class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></div></div>'; } else { $img->parent->parent->class = $img->parent->parent->class . ' no-align uk-display-inline-block'; $img->outertext = '<div class="uk-overlay uk-overlay-hover">' . $img->outertext . '<div class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></div></div>'; } $img->parent->class = 'uk-thumbnail'; $img->class = null; break; } } //add manipulations to body field $page->body = $bodydom; } } Thats all! All these elements will be enriched with UIKit 2 Markup. Remember: If Simple HTML Dom Parser is not correctly installed, you will get an error. Some of the styles I use are the ones that I prefer. Maybe you prefer an other style that UIKit offers. So you can change the CSS classes to your prefered style. This code only should give you an inspiration on how to manipulate markup. Best regards.
  6. I have also written the login/logout system on my own (I needed UIKit Markup and some other customizations). To prevent spam I use this Honeypot class and I have no problem since then. It make several tests before letting the user go further. I have installed it via composer so updating is also no problem. So its a look worth while. Best regards
  7. Thanks for the great module. It would be awesome if you make the link text " Generate password " translateable
  8. Doesn`t work in 3.0.78 too. Inputfield will be always blank if default value is entered.
  9. I have created a set of inputfields for recurring events. There you can choose between daily, weekly, monthly yearly and you can choose between an enddate or a number of repeats (and of course some other options). The if condition depends on a select option fieldtype. If you choose "repeat until a certain enddate" then the enddate field needs to be filled out (required), if you choose to repeat the events until a certain number of repeats (fe 10 repeats), then the enddate field is not required. All the fields are in the new fieldset(Page) fieldtype.
  10. Because I would have to write a lot of hooks and that is what I want to prevent .
  11. Ok, thanks for your tipps. It is not really necessary to put the fields inside a fieldset(Page) field - it would only save me a lot of time. I will put it inside a default fieldset and copy it as usual.
  12. Hello @ all, I am trying to copy the values of the new fieldset (Page) type fields via API to a child page. Its a kind of repeater so I have tried to copy it like this: $k->eventdatesfieldset->import((wire('pages')->get($page->id))->eventdatesfieldset); "eventdatesfieldset" is the name of the fieldset. I have tried it with the import function like in repeaters but I always get the message "Method FieldsetPage::import does not exist or is not callable in this context". Does anyone has tried to copy fields from this new fieldtype and has a working solution? I want to copy the values to the child page. Best regards
  13. It would be great if "required if" conditions in repeaters inputfield dependencies will work in the future. At the moment only "show if" conditions work. Today I have implemented the new fieldset (Page) type, which works like a repeater. But unfortunately I had to remove it because of the non working "required if" conditions. In my case I need the "required if" condition and therefore I had to switch back to a default fieldset (which supports the "required if" condition dependency). But it was more work and I needed more fields. So this feature would save a lot of time. Maybe it will be possible in the near future. Would be great!
  14. Hello @Missariella, however, I am using the latest dev version (3.0.76) and its working. First of all I recommend you to create a global translation piece of code. Put it somewhere in a file that is loaded everytime (fe. a function.php), so the translation code will be availiable everywhere. You can put it also in the template file where you want to output the select options, but loading it in general makes more sense in this case, because you can use it in other templates too. Here is the code: //get labels, title, values and descriptions in different languages if ($user->language->name != 'default') { $title = "title{$user->language}"; $value = "value{$user->language}"; $label = "label{$user->language}"; $description = "description{$user->language}"; $notes = "notes{$user->language}"; } else { $title = 'title'; $value = 'value'; $label = 'label'; $description = 'description'; $notes = 'notes'; } This little code snippet makes titles, values, labels, descriptions and notes available in all languages by only calling "$title" instead of "title" (or "$label" instead of "label" and so on...). So it makes your life much easier Afterwards creating a multilanguage select can be done like this: $options = $fieldtypes->get('FieldtypeOptions')->getOptions($fields->get('YOURFIELDNAME')); foreach ($options as $value) { echo $value->$title; echo $value->$label; echo $value->$description; } This outputs title, label and description in the user language. This is the code that I am using on my projects without any problems.
  15. Thank you all for your tipps. These are all interesting options. I am not sure, which opiton I will choose at the end, but now I have some ways to go on further.
  16. Hello @ all, I have a some templates which will be loaded via AJAX. They are located in a separate folder under site/ajax/ so they are not in the PW template folder. I have bootstraped these templates via "include("../../index.php");" so I can query PW fields via API calls. It works quite well and I get all values from my PW fields. Unfortunately if I switch the language from German to English, all values will stay in the default language (German). So the language change will not be taken into account, because there are no different urls for each language (no PW pages). Has someone dealed with the same problem and could give me a hint how to take the language change into account? My idea was to add a query string with the id of the language at the end of the AJAX href (like "path/to/myajaxtemplatefile?id=1008) but maybe someone has a better idea. I dont want to create a real PW page for such small piece of information. Best regards
  17. Yep, that was the problem! Now it works.... I only use it for testing purposes at the moment..... so this is not a problem. Thanks for your quick help and response!!
  18. Thanks @bernhard but the problem is only there by installing or upgrading Handson tables. I did a lot of other updates (PW, some field types and modules,...) - without any problems. I guess you mean how, because I did it to get the latest version? I made it with the default PW update - like all others. After the update failed, I deinstalled and deleted the module. Afterwards a fresh install of the module was done from the PW module directory. There are no other error messages than the one I have posted above. I have Tracy running beside - but no error message. Best regards
  19. Hello @bernhard, I have tried to update Handson tables but I always get this error: It also happens after uninstall and deletion of the older version and a fresh install. Best regards Jürgen
  20. I use it on the latest PW 3 DEV without any problems.
  21. @szabesz I can confirm this behaviour.
  22. I also had some troubles with sessions and form data sometimes ago. In my case I wanted to store multiple infos (fe first name, last name, email,...) inside a session. I have tried it with an array, but this didnt work. So I ended up to put my form data into an array and convert this array into a json array before storing it into a session and this works. After that I have outputed the form data by converting back the json array to a standard array (so jsonencode, jsondecode) was the key of success for me to work with multiple data and sessions. Best regards
×
×
  • Create New...