-
Posts
1,306 -
Joined
-
Last visited
-
Days Won
13
Everything posted by Juergen
-
Maybe that could be the reason!!! My child pages have the same title because it is always the same event (only the starting date will change). I will try it to add the number at the end (fe. event-1, event-2,...). I have manipulated the path names to add the starting date at the end (event-21-12-1016, event-28-12-1016 and so on). Therefore I never had a problem to store sub events with the same title. I will give it a try
-
Mmmhh! It works in your case. I run the latest dev version of PW (3.0.45) $page is the parent page. I run a hook to create the child pages. This is how $page is defined inside the hook function: $page = $event->arguments[0]; So $page is always the page that you are working on (the parent page). Only for better explanation: It is a complex children creating function that is running with the hook. It creates children with different start dates depending on the settings. So the start date array is called $periods in my case. It is responsible for creating the children. If fe 5 dates should be created with an interval of 1 week than the period array consists of the five calculated start dates. Here is an example: $periods = array('21.12.2016', '28.12.2016', '04.01.2017', '11.01.2016'); This is why my foreach loop doesnt look like foreach ($children as $title) { Instead of this it looks like foreach ($periods as $item) { Thats the only difference. This is the complete foreach loop which is responsible for creating the child pages and filling their fields with values from the parent page. foreach ($periods as $item) { // create new page $k = new Page(); $k->template = 'single-event'; // set template $k->parent = wire('pages')->get($page->id); // set the parent // Copy page fields from parent page to newly created child pages $k->date_start = $item; $k->eventpricerepeater->import($page->eventpricerepeater); $k->publish_until = $item + $diff; $k->eventstatus = $page->eventstatus; $k->participantmaxnumber = $page->participantmaxnumber; $k->eventmaxstatus = $page->eventmaxstatus; $k->eventmaxstatus = "1"; //get start date and create path name $eventstartmultiple = date("Y-m-d", $item); //get date for URL $k->title = $page->title; //check for other languages foreach ($this->languages as $lang) { $lname = $lang->isDefault() ? '' : $lang->id; $default = $this->languages->get("default"); if ($page->title->getLanguageValue($lang)) { $k->set("name$lname", $page->title->getLanguageValue($lang) . '-' . $eventstartmultiple); } else { $k->set("name$lname", $page->title->getLanguageValue($default) . '-' . $eventstartmultiple); } $k->set("status$lang", 1); //$k->of(false); $k->save(); } } I will try to adapt it to your code and post the result here.
-
Away from the deletion of the children repeater pages - it seems that there is still a problem by copying the repeater to the children pages $k->eventpricerepeater->import($page->eventpricerepeater); It seems that the repeater page will not be copied (created) to the children pages, because the page name is the same as in the parent (Duplicate-Entry). There exists only one page from the parent page (1482132297-8942-1) and it seems that the same page name will be copied to the children pages and therefore I always get the duplicate entry error. As a result the repater pages will not be created - so the deletion process will not take place. Here is the beginning of the code which creates the children pages foreach ($periods as $item) { // create new page $k = new Page(); $k->template = 'single-event'; // set template $k->parent = wire('pages')->get($page->id); // set the parent $k->setOutputFormatting(false); // Copy page fields from parent page to newly created child pages $k->date_start = $item; $k->eventpricerepeater->import($page->eventpricerepeater); $k->eventstatus = $page->eventstatus; .............. .............. This piece of code works because all fields except the repeater fields will be copied to the children pages.
-
Ok, my child pages need to be called in a foreach, cause there are more than one: foreach ($page->children("include=all") as $child) { $repeaterID = $child->get('eventpricerepeater')->id; $repeaterPage = wire('pages')->get("parent.name=repeaters, name=for-field-$repeaterID"); if($repeaterPage->id) $child->delete($repeaterPage, true); $child->delete(); } I run the code from a module, therefore I use "wire('pages')" instead of $pages. Unfortunately the code doesnt delete the repeater pages.
-
Hello @kongondo your code works. I only get a notice from Tracy: but thats not a big problem. I am running Tracy in strict mode. A new problem occurs: Everytime I start to create the child pages with the API the "old" child pages including the repeater must be deleted. The child pages will be deleted but not the pages created by the repeater. These are the pieces of code that I have tried but without success. foreach ($page->children("include=all") as $child) { $child->delete(); //delete all children first } OR foreach ($page->children("include=all") as $child) { foreach($child->eventpricerepeater as $r) { $r->delete(); } $child->delete(); //delete all children first } The undeleted repeater pages lead to the SQL-error for duplicate entry.
-
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.