-
Posts
1,348 -
Joined
-
Last visited
-
Days Won
16
Everything posted by Juergen
-
Hello @ all, does anyone know how to copy all the field values of a repeater from a parent page to a child page via the API. I know how to do it with standard fields (fe textfields) but repeaters are more complicated. Scenario: I have a parent page (fe a page about an event) and via a hook I create several child pages (fe all the dates for this event). During the creation process I copy several field values from the parent page to the new created child pages. For standardfields I copy the value like this: $k = new Page(); $k->setOutputFormatting(false); $k->participantmaxnumber = $page->participantmaxnumber; //copy the field participantmaxnumber from the parent to the child page $k->save() But how can I achive the same by copying a repeater with several fields in it. This doesnt seem to work: $k = new Page(); $k->setOutputFormatting(false); foreach($page->eventpricerepeater as $repeateritem) { $repeateritem->earlybookingdeadline = ...; } $k->save() I have also tried $k->eventpricerepeater = $page->eventpricerepeater; but without luck. Has anyone done this in the past and knows how to copy repeaters and its items? Best regards
-
I have also this problem sometimes (especially when I am not logged in). Could it be possible that there is a limit on the Leaflet service which supports only a specific amount of requests to a certain domain?
-
Great @tpr Many Thanks!!!!!!! Unfortunately it only fetches the label in the default language, but anyway.
-
Nice feature!! Is there a way to add the label of the field in the tag? Instead of hardcoding "images" in [em][i]images: {images.count}[/i][/em] is it possible fe to output the label of the image field like [em][i]{images.label}: {images.count}[/i][/em] My site is multilingual and therefore it would be nice if the word "images" could be available in several languages. If not, anyway! Best regards
-
How to deal with translation file in changed file location
Juergen replied to Juergen's topic in Multi-Language Support
No, no idea! I let it on the same position. I didnt get it to work. -
Hello Ryan, after updating from 3.042 to 3.0.43 dev I always get the following error if I want to load my page tree: Maybe you can take a look at the Page.php. Best regards
-
Is it possible to show a page table only if there are items in it?
Juergen replied to Juergen's topic in General Support
Thanx @Alfred I have corrected this. -
Module updated! There were some cases where the module has produced an error on boolean. This happens if the field where you have added the Textformatter is on the page but it is still empty. Then the manipulation functions fail. I have corrected this with a simple if condition check to prevent this error.
-
Its only here for creating the label and will not be displayed as a field in the template (see field settings below). I only use it to enter the day of the week (fe Monday). As you can see in my previous post every repeater has the name of the day in the repeater label. Field settings of the hidden field:
-
-
Very useful! I use it in combination with opening hours. For this reason I have created a repeater with 7 repeats (one for each day). In this case it prevents the customer from deleting or draging a weekday from the repeater list.
-
Code was rewritten to force better integration with CKEditor. I have discovered problems with additionaly added figure tags and CKEditor. The editor has produced several empty paragraph tags. Replacing figure tags (block elements) with span tags (inline elements) has solved this problem and validates against W3C validator. The manipulation code was also rewritten for better readableness. To see all changes please visit the Github page. @flydev I have tried to make the manipulations with native dom, but unfortunately it doesnt support HTML5 tags, so I have to use an external library.
-
Thanks for your hint @horst the included file is an external library and for update reasons I prevent it from changes. Otherwise I have always to take care of my changes after updates. My first thought was that if I use "require_once" to include the file would prevent it from loading more than 1 time, but unfortunately this doesnt work.
-
Bug: Missing figure tags if image has no alignment class has been corrected.
-
No the zip file only includes the testing if a special function called "file_get_html" exists. It has nothing to do with str_get_html. You can also test for "str_get_html". These are special functions of simple_html_dom.php. I only check if they are loaded before in another instance - if not then include the php file. The problem is that if they were loaded before you will get a "cannot redeclare class" error. You can send me temp access data via PM and I will try it.
-
I have included a check if "simple_html_dom.php" is included by another module before, because I ran into an issue where 2 Textformatter modules use this file and both have included it. I have used "require_once" to prevent this behaviour but unfortunately it doesn work. Therefore I run a check before the "require_once" which checks if a special function is loaded before. //check if simple_html_dom.php is included by another module before - prevent double including if (function_exists('file_get_html')) { //check for the file_get_html function //do nothing } else { require_once 'simple_html_dom.php'; } Description: If the function "file_get_html" is loaded before by another module, skip the including of the simple_html_dom.php. It works but if anyone has a better idea please let me know. The update is included in the download link of the first entry.
-
It could not be empty if something is in your body field. I dont think that there is js conflict, but you can try to disable the plugin for testing purposes. It is quite difficult for me, because in my case everything works as expected. It would be good if another person would install the module and try it out if it works. <?php /** * TextformatterUIKitImages (0.0.1) * This little Textformatter adds UIKit classes and markup to images added with CKEditor * Uses simple_html_dom.php because native dom makes problems by using HTML5 tags * @author Juergen Kern * * ProcessWire 2.x * Copyright (C) 2011 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class TextformatterUIKitImages extends Textformatter implements Module { public static function getModuleInfo() { return array( 'title' => "TextformatterUIKitImages", 'version' => "0.0.1", 'summary' => "This little Textformatter adds UIKit classes and markup to images added with CKEditor", 'author' => "Juergen Kern", 'singular' => true, 'permanent' => false, 'requires' => array( "PHP>=5.4.0", "ProcessWire>=2.5.28", "" ) ); } public function format(&$str) { //check if simple_html_dom.php is included by another module before - prevent double including if (function_exists('file_get_html')) { //check for the file_get_html function //do nothing } else { require_once 'simple_html_dom.php'; } $html = str_get_html($str); //Manipulating figcaption with uikit css class $figcaptions = $html->find('figcaption'); foreach ($figcaptions as $caption) { $caption->class = 'uk-thumbnail-caption'; //add class to figure caption tag } foreach (($html->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; } } $str = $html; } }
-
Mmmhh! A function like " $html->find" is a syntax of the dom file. Line 35 is the following: foreach (($html->find('img')) as $img) { if the file is integrated properly, it must work. I use simple_html_dom.php on another module too without problems. Have you tried to deinstall and delete the module first?
-
Could you please copy the code of line 35 (or even make a screenshot) of the file compiler file.
-
Please try to delete the file compiler cache. I have installed and deinstalled this module several times for testing purposes and it works in my case. I use the latest PW 3.0.41. Maybe you can even try to deinstall the module and reinstall it. I am always running Tracy beside and I got no errors. It seems that simple_html_dom.php is not present in your file compiler cache, because you have uploaded it afterwards.
-
Hello, I have written a small module which adds UIKit Framework markup to images added with CK-Editor Here are some screenshots: 1) Default view 2) Hover over image shows an overlay and a tooltip info 3) Open in UIKit lightbox How does it work? The module uses Simple HTML DOM Parser for all the manipulations, so this file is also included in the module folder, but it doesnt add any UIKit CSS or Javascript. So you have to load the UIKit framework by yourself. What manipulations take place? Adds UIKit CSS classes to various tags (figure, anchor, image) Adds "no-align" class to tags (figure, image anchor) without alignment, so it could be also styled with CSS Adds an extra surrounding span container to images with no alignment and no figure tag to force block element behaviour Adds UIKit lightbox attribute to linked images Adds image alt attribute as title attribute for linked images on anchor tags / creates fallback if no alt attribute is present Adds UIKit tooltip attribute to all anchors of linked images (tooltip text can be translated in the module translation file) Adds UIKit overlay containers (additional markup) to linked images for overlay effect on hover Example of Markup manipulation: BEFORE <figure class="align_left hidpi"> <a href="/site/assets/files/5556/bora_bora_3.jpg"> <img alt="Rochen" src="/site/assets/files/5556/bora_bora_3.150x0-is-hidpi.jpg" width="150"> </a> <figcaption>Rochen</figcaption> </figure> AFTER <figure class="uk-align-left hidpi"> <a href="/site/assets/files/5556/bora_bora_3.jpg" title="Opens the image in a lightbox view" data-uk-tooltip="" data-uk-lightbox="{group:'my-group'}" class="uk-thumbnail"> <div class="uk-overlay uk-overlay-hover"> <img alt="Rochen" src="/site/assets/files/5556/bora_bora_3.150x0-is-hidpi.jpg" width="150"> <div class="uk-overlay-panel uk-overlay-background uk-overlay-icon"></div> </div> </a> <figcaption class="uk-thumbnail-caption">Rochen</figcaption> </figure> How to install the module? Download the module: TextformatterUIKitImages.zip Github: Download from Github Extract the folder and upload the unzipped folder (including both files - simple_html_dom.php, TextformatterUIKitImages.module) into the site/modules folder. Please let both files into the TextformatterUIKitImages folder - TextformatterUIKitImages (folder) -|- TextformatterUIKitImages.modules (file) -|- simple_html_dom.php (file) Install the module as all other modules and add it f.e. to the body field. Hint: I dont maintain the module, so its only here for people who are using UIKit framework too and want to manipulate the image markup of images added with CKEditor. It can also be used as a starting point for your own image markup manipulation module. Best regards Jürgen
-
Hello Can, I am using TextareaLanguage field as my body field. Therefore I got fe an error message at "$value->getLanguageValue($user->language)" - this could not be used with a string. Anyway, I have written my own image markup manipulation module using simplehtmldom. I am using UIKit as my framework and I have to include the UIKIT CSS classes and markup for images inserted with CKEditor. I have used your module as starting point for mine. Best regards
-
Doesnt work at all, There are a lot of error messages reported by TracyDebugger