Jump to content

Tyssen

Members
  • Posts

    354
  • Joined

  • Last visited

Everything posted by Tyssen

  1. Every page is going to use the repeater matrix but only the home page is going to need to have the repeater as well so I was trying to find a solution that would keep the repeater option out of the matrix field, but I guess it's not that big a deal really, so I'll go with that.
  2. Thanks guys, I think I have it working, but I'm waiting for feedback from the content editor because I'm unsure if the output is as expected.
  3. I have two fields on a page, one a normal repeater and the other a repeater matrix. What I want to be able to do is allow the content editors to choose to insert the content from the normal repeater field in between other content in the repeater matrix field. I thought I could insert some text into the repeater matrix and then do a conditional in my templates to check for that string and insert the other field's output there. My template looks like this at the moment: home.php $inserted = 'Data from the normal repeater field created with a foreach loop'; $page->render('repeater_matrix_field'); repeater_matrix_field.php foreach($value as $item) : echo $item->render(); endforeach; matrix_body.php if($page->heading=='Replace this') : echo $inserted; else: echo '<h2>'.$page->heading.'</h2>'; endif; I don't get any output I guess because the $inserted variable doesn't get passed from home.php to the other templates. So is there a way to do that, or is there a better way to achieve what I'm trying to do?
  4. I then get an error on the next line. And in testing whether $randomPage was actually returning anything by just outputting the page title, I'm getting instead of repeater items randomised from Pages A–E.
  5. With $randomPage = $pages->get("id=1049|1053|1055|1059|1152")->findRandom(1); or getRandom(1) I get
  6. I have a series of pages that use a repeater field and I want to fetch 3 random rows from each repeater from 5 specific pages, so that I'll have a total of 15 items output, but then also randomise the output so that items from the same repeater field aren't next to each other. Originally I had $selected_pages = $pages->getById([1049,1053,1055,1059,1152]); foreach($selected_pages as $selected_page) : foreach($selected_page->repeater_field->getRandom(3) as $item) : Output endforeach; endforeach; That gave me the pages randomised, but also gave me the items from each page's repeater next to each other. So then I tried $selected_pages = $pages->get("id=1049|1053|1055|1059|1152")->repeater_field->find("limit=15, sort=random"); but that's just randomly pulling 15 items from the first page, the one with id 1049. How do I go about randomising both the pages and the repeater items as well?
  7. Yes it is. I'm contacting the hosting company about it now. Why would it only be triggered after adding a second textarea field though when the first one works fine? :?
  8. I have a repeater field that contains title, an image field and two text fields, one for teaser and one for body. I can add data to all the fields except the teaser OK and save the page. As soon as I try adding text to the teaser field, I get a 403 error. The teaser field was using CKEditor, but I've now changed it to just a plain textarea but still get the same error. Anyone know what might be causing that?
  9. Yep, that did it. In all the Googling I've done on how to do this, that page in the docs never came up. The ProcessSetupPageName module did though which is why I attempted to use that first.
  10. No, single language. But just in case, where would that be set?
  11. I also tested "string".date(U) and got tue-12-feb-2019-15-30-03-1000australia-brisbane2019-02-12t15-30-03-10-0003pmtue-12-feb-2019-15-30-03-10003australia-brisban ?
  12. That's what I can't work out, because date(U) is all that's there.
  13. I'd actually installed the SetupPageName module before I realised there was a native name format for children field but with it installed, I got errors when trying to add new pages, so I installed it. But I wonder if it's done something which is causing this behaviour? Oh, and I don't have anything in init or ready which would be causing it.
  14. I'm using a single page template with Name format for children filled in with date(U) so the children have their name field automatically filled with the UNIX timestamp, but when I save entries it's coming out in the format 11am28australia-brisbane-1549849103. How do I only get the time stamp at the end?
  15. I'm getting the same error with PW 3.0.62. I installed it, updated my parent template with the format I wanted to use and then went to create a child page. I got the error, uninstalled the module as suggested by Macrura and refreshed the page I was trying to create and got redirected to page/edit/?id=XXXX&new=1 and it had created the name/title in the format I'd specified. Now I can create more child pages which automatically skip the add new page and have the expected name/title format, even though the module is no longer installed.
  16. Right, changing it to $month = date('m') seems to have fixed it.
  17. I have three events all in October and I want my events page to list events under the month of their date field. But with the below code I get two under September and one under October. The date field values for the three events is: 2018-10-13 00:00:00 2018-10-20 00:00:00 2018-10-27 00:00:00 What am I doing wrong? function childrenInMonth($page, $month, $field = 'event_date') { $startTime = $month; $endTime = strtotime("next month", $startTime); return $page->children("$field>=$startTime, $field<$endTime, sort=$field"); } $events = ''; $start = $month = strtotime('today'); $end = strtotime('+1 year'); while($month < $end) : $event_pages = childrenInMonth($page, $month); if(count($event_pages)>0) : $events .='<h2>'. date('F', $month).'</h2> <ul>'; foreach ($event_pages as $event) : $events .= ' <li> <h3>'.$event->title.'</h3> </li> '; endforeach; $events .= '</ul>'; endif; $month = strtotime("+1 month", $month); endwhile;
  18. I'm getting the following error on a production site: I don't get the error on my local version of the site. Why does it happen in production and not local? I guess it would be solved by PW not adding anything from the vendor folder to cache/FileCompiler, so how do I stop that? Or is there something else I should be doing to fix it?
  19. How would you go about adding markup to an action outside a form field? For instance for an action I'm working on which sends emails, I'd like to be able to provide a button to preview the email in a modal window. Would it be with addHookAfter and if so, would I be targetting the action's class::method or the module's?
  20. I'm customising one of the actions that comes with the Admin Actions module and would like it to display a repeater matrix field. I've created a field in PW then gone to Export and copied the output and then pasted it into my action converting it from JSON to PHP format, so this is what I have: array( 'name' => 'emailBody', 'label' => 'Email body', 'description' => '', 'type' => 'repeaterMatrix', 'matrix1_name' => 'page', 'matrix1_label' => 'Choose existing page', 'matrix1_head' => '{matrix_label} [• {matrix_summary}]', 'matrix1_sort' => 1, 'matrix2_name' => 'text', 'matrix2_label' => 'Text', 'matrix2_head' => '{matrix_label} [• {matrix_summary}]', 'matrix2_sort' => 2, 'matrix1_fields' => array(2), 'matrix2_fields' => array(76), 'repeaterFields' => '', 'repeaterLoading' => 1, 'rememberOpen' => null, 'repeaterMinItems' => 1, 'matrixN_head' => '{matrix_label} [• {matrix_summary}]', 'columnWidth' => 100 ) When I load the action page I get: from FieldtypeRepeater/InputfieldRepeater.module at line 216 I haven't done anything with PW admin pages or modules before so I'm not really sure what I'm doing or whether this is the right approach. I'm posting in a separate thread rather than the official support thread as what I'm having trouble with has more to do with my understanding of how the PW API works in admin pages than with the actual module itself. cc @adrian
  21. I actually want a Repeater Matrix field, not PageTable. I'm trying to implement this now and have created a field in PW then gone to Export and copied the output and then pasted it into my action converting it from JSON to PHP format. Is that the right way to go about it? Or can I point the field in the action to an already existing field? Will I be able to use any fieldtype in an action?
  22. All good now, thanks. ? I've got quite a bit more I want to do with this action like be able to use a PageTable field to be able to compose emails from a mix of existing pages and typed content, preview the email before sending, attach files uploaded to pages, and log email sends, but I think I'm probably better creating a new thread for that as it won't really be specific to your module, but more my limited coding abilities and inexperience working with the API.
  23. If you pasted the code I posted above into an action to test, it's probably because I removed all the bits I didn't change to make it shorter and easier to read. I added comments where I'd taken stuff out. So testAddress, email, body, etc. all exist in my version of the action. I had missed one $options['fromEmail'] which I've now changed to $options['from'] but other than I'm not getting any other errors. I've attached the action file if it helps. EmailBatcherCoordinator.action.php
×
×
  • Create New...