Jump to content

Mr. NiceGuy

Members
  • Content Count

    24
  • Joined

  • Last visited

Community Reputation

4 Neutral

About Mr. NiceGuy

  • Rank
    Jr. Member

Recent Profile Visitors

1,679 profile views
  1. I just had this same problem (some error in the translation csv I uploaded) and I fixed it through navigating to the admin page id folder in site/assets/files/LANGUAGEPAGEID/ and deleted all my templates*.json translation files.
  2. Did some more digging and turns out that $pages is available but it does not find the pages with the template that I am looking for. For example if I look for pages with template "basic-page" they are displayed in the PageTableExtended render, in the single page and in the frontend render. But if I look for the two specific templates in $pages-> that I want to display they are not shown. I checked the template name x times and also added include=hidden in the $selector and have no idea why they are not displayed. The name of the template is quite long but that should not matter, right? (16 chars). This is how it looks in PageTableExtended This is the front end:
  3. I'm having troubles using $pages->find and render(). I have a PageTable Field which holds pages that are saved under the admin. E.g $l has template "pagetableTMP" and is located under /admin/contentblocks/ if(count($page->content)>0){ foreach($page->content as $l){ $content .= $l->render(); } } In the frontend I render them like this where "content" is the PageTable field. In the template for $l there is this code: foreach ($pages->find('template=tmpname, sort=title') as $c) { echo " <tr class='hover:bg-gray-400'> <td class='py-4 px-6 border-b border-gray-300'>{$c->title}</td> .... </tr>"; } When I look at $l as a single page I get the correct output. However, when I look at the page with the $content field which should render $l I get no output at all because $pages is empty. The pages with template "tmpname" are not in the admin but are normal front-end pages.
  4. Thanks bitpoet. Must have overlooked the clone function. And yes you understood it correctly that I wanted to create those virtual instance only on rendering. In the end I however decided to create real pages kind of like MuchDev suggested via module by hooking into the save function of the single-event pages. The admin for the single-event template now looks like this: https://monosnap.com/file/t187kaF2xI7WxF79blA3D982uMT1ko The code for the module is as follows. Adapt it for your needs <?php class recurringEvents extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Recurring Events', 'summary' => 'Adds a function to create recurring events and add pages to Processwire when a checkbox is checked on page save', 'version' => 1, 'autoload' => true, ); } public function init() { $this->pages->addHookBefore('save', $this, 'hookSave'); } public function hookSave($event) { $page = $event->arguments[0]; # check if recurring is checked on the page beeing saved. if ($page->recurring==1) { $intervallString=$page->intervall->title; for ($i=1; $i <= $page->n_repeats; $i++) { // create new page $k= new Page(); $k->template = 'single-event'; // set template $k->parent = wire('pages')->get('/events/'); // set the parent $intervall='+'.$i.' '.$intervallString; // construct the $intervall selector for strtotimestamp +1 week or +1day, increase with iteration by 1 $k->setOutputFormatting(false); // Copy page fields from current page to newly created one $k->title=$page->title; $k->organisation=$page->organisation; $k->type=$page->type; $k->location->address=$page->location->address; $k->body=$page->body; $k->recurring=0; $k->dateStart= strtotime($intervall, $page->dateStart); $k->dateEnd = strtotime($intervall, $page->dateEnd); $k->save(); } $this->message("Sucessfully created ".($i-1)." copies of recurring event {$k->title}"); // on the current page set recurring to 0 again, no page->save() needed because the page will be saved after the hook automatically $page->recurring=0; } } }?>
  5. Thanks for the code examples gebeer, unfortunately they don't contribute to solving my problem. The +1week example is nice and elegant. Didn't know that one. You are right, my field intervall returns indeed a timestamp of a time point. The input field for the intervall asks the user to enter the next date when the event should occur. Then I calculate the time difference between the two events. I want to implement it like this because I think that this is the simplest solution to the probem. Probably not the most elegant one though Maybe I should have made that clearer. However your post doesn't solve my problem that I can't add multiple instances of the same page with different start/end dates to the same page array. Any ideas how can I achieve this?
  6. I use the following code to make instances of an event with the template single-event to make it recurring. Recurring events have the field recurring checked and in the intervall I let the user specify a time range (as timestamp) until the next event. What I now want is to display the original event and create 5 instances (each one intervall step further in the future). What I now have: $today=time(); $results = $pages->find("template=single-event,dateEnd>$today, recurring=0, limit=25"); $recurring = $pages->find("template=single-event,recurring=1, limit=25"); foreach ($recurring as $k) { for ($i=0; $i < 5; $i++) { $start=$k->dateStart+$i*($k->intervall-$k->dateStart); $end=$k->dateEnd+$i*($k->intervall-$k->dateEnd); $k->set("dateStart", $start); $k->set("dateEnd", $end); $results->add($k); } } $results->sort("dateStart"); What I get is only the second item i want to have (dateStart+intervall*1). How do I get the other ones with $i=0 and $i>1? I assume this doesn't work because the ids of the pages I add to the calendar are the same. Am I right?
  7. I'm building a knowledge base profile. What I'm currently on: A user with the role guesteditor gets logged in and is allowed to add a page with the parent "drafts". After the guesteditor saves his page I want to notify an admin who then moves the new page if any good to its destination. So far so good. My question now is if I can change the names and behaviour of the Publish and Save+Keep Unpublish Button to a Single "Request Permission from Admin" Button. After the button is clicked I would like to send an email to admin, save a value to the same page that the permission request was sent and display instead of the button a message like "permission requested on xx.xx.2015" How do I do this? I'm planning to write an autoload module like described here https://processwire.com/talk/topic/2331-doing-additional-logic-after-saving-a-new-page/ to populate some fields through the URL that the guesteditor clicks to add a new page. Are there similar methods to do the thing described above? Thanks!
  8. As the last answer is nearly a month old now. How is the status on this?
  9. Okay so a litte more detail to this. My Tree: Start -Itemroot ----Item 1 -------Item2 -Categoryroot ---Category ---subcategory I edit item1, which has the field pageselect assigend but unpopulated. (The Fieldtype is PageListSelectMutliple*+) . I then Create the page subcategory and publish it in a new tab. I close this tab and go back to my page Item1. The pageselect lets me select my newly created subcategory because it loads all available pages via ajax. When i hit save on item1 i get the forged request error. When reloading and saving afterwards it works. Im using 2.4 with default Theme. I tried two seperate installations on localhost and hosted server.
  10. Yep it works fine if you refresh page1, but if you dont refresh it will throw the forged request error. In my use case its pretty common to add new categories to the system while typing the main text. All progress during writing is lost if i just reload the page.
  11. How does PageFoldStatus work? Do i have to activate it somewhere. I installed it but my expanded page list does not stay when reloading the page.
  12. Hey Guys, two small Questions: First: I get reproducable errors for forged requests: The scenario is as follows: I edit a page. In another browsertab I insert another page into the page tree for example a category page. The first page i began to edit has a page selector "Category select". When I select the page i just created in the other tab and save my first page I get the "Forged request" error. Is this intended? On a quick forum research I found similar topics but they all seemed to deal with login problems. Second: Is there a way to allways have the page tree expanded ? I had a look in PageList.js but did not find a option to disable the auto-collapsed list.
  13. Superb, Works great! Thanks to everyone taking the time
  14. Hej Diogo, thanks for your efforts I tried your last code example and played with it. Seems to work fine with two and one level but I cant get higher levels to work? Have you tried 4-6 levels? . The iteration is going through all the 5 levels but your algorithm for the parents doesnt work out: All the pages of the respective level are included but two or three times depending on the level depth. 1049|1050|1056 --1049|1050|1056|1050|1051|1056 --1049|1050|1056|1050|1051|1056|1050|1051|1052|1053|1056 --1049|1050|1056|1050|1051|1056|1050|1051|1052|1053|1056|1012|1036|1050|1051|1052|1053|1054|1055|1056 Thats an example of the ouput for 4 levels. I tried some stuff but im rather a noob at php and have no idea what could be the problem //Modified code by me $allParents = $parents . '|' . wire('pages')->find("parent={$parents}"); // add new parents to existing echo $allParents ." --"; with Level depth of 5
  15. Yep, I just need an array for every item like this [{itemid,parentpageid,text}], .... The nested traversal function from the sitemap looks good. Seems easy to implement a counter and restrict the level depth. I'll have a look at it next week and post my solution. Thanks for the input!
×
×
  • Create New...