Jump to content

psy

Members
  • Posts

    718
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by psy

  1. @bernhard Grateful for the offer to help, however on a tight schedule and managed to get the solution to my query using a normal PW selector with the very helpful and hard to find gem "repeater_field.owner.field_name'. It enabled me to get the repeater field, it's originating page and the individual repeater item data. The selector returns a WireArray of repeater fields which are then manipulated into a flat array for RockTabulator. From what I could see in the SQL statement from RF3, the field table aliases are getting mixed up when both the first and main RF3 queries have the same field name, eg 'title' - some have the unique id twice and then the LEFT JOIN 'title' gets the wrong one which then fails.
  2. Same result. I tried that first before changing the column name to 'booking'
  3. Don't know what I'm doing wrong but cannot join two RF3 statements when both have the field 'title'. I based it on the example of: <?php $owners = $rockfinder ->find("template=person") ->addColumns(['title', 'age']) ->setName('owner'); // set name of target column $rockfinder ->find("template=cat") ->addColumns(['title', 'owner']) ->join($owners) ->dump(); My case is field 'booking_status' is a page reference field in template 'booking'. <?php $rockfinder = modules("RockFinder3"); $booking_status = $rockfinder ->find("parent.id=1154, include=all") ->addColumns(['title']) ->setName('booking_status'); $rockfinder ->find("template=booking") ->addColumns(['title'=>'booking', 'booking_status']) ->join($booking_status) ->dump(); Each one individually returns the correct data. However when I try to use the join, it errors with "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxxxx_xxxx.field_title_5ee33d16934fa' doesn't exist". Both templates have a 'title' field. The SQL dump is: "SELECT `pages`.`id` AS `id`, `_field_title_5ee33bf3cb7d8_5ee33bf3cb854`.`data` AS `booking`, GROUP_CONCAT(DISTINCT `_field_booking_status_5ee33bf3cb92f`.`data` ORDER BY `_field_booking_status_5ee33bf3cb92f`.`sort` SEPARATOR ',') AS `booking_status`, GROUP_CONCAT(DISTINCT `join_booking_status_5ee33bf3cbbbe`.`title`) AS `booking_status:title`, GROUP_CONCAT(DISTINCT `join_booking_status_5ee33bf3cbbbe`.`booking`) AS `booking_status:booking`, GROUP_CONCAT(DISTINCT `join_booking_status_5ee33bf3cbbbe`.`booking_status`) AS `booking_status:booking_status` FROM `pages` LEFT JOIN `field_title_5ee33bf3cb7d8` AS `_field_title_5ee33bf3cb7d8_5ee33bf3cb854` ON `_field_title_5ee33bf3cb7d8_5ee33bf3cb854`.`pages_id` = `pages`.`id` LEFT JOIN `field_booking_status` AS `_field_booking_status_5ee33bf3cb92f` ON `_field_booking_status_5ee33bf3cb92f`.`pages_id` = `pages`.`id` LEFT JOIN ( SELECT `pages`.`id` AS `id`, `_field_title_5ee33bf3cb5c3`.`data` AS `title`, `_field_title_5ee33bf3cb7d8_5ee33bf3cb854`.`data` AS `booking`, GROUP_CONCAT(DISTINCT `_field_booking_status_5ee33bf3cb92f`.`data` ORDER BY `_field_booking_status_5ee33bf3cb92f`.`sort` SEPARATOR ',') AS `booking_status` FROM `pages` LEFT JOIN `field_title` AS `_field_title_5ee33bf3cb5c3` ON `_field_title_5ee33bf3cb5c3`.`pages_id` = `pages`.`id` LEFT JOIN `field_title_5ee33bf3cb7d8` AS `_field_title_5ee33bf3cb7d8_5ee33bf3cb854` ON `_field_title_5ee33bf3cb7d8_5ee33bf3cb854`.`pages_id` = `pages`.`id` LEFT JOIN `field_booking_status` AS `_field_booking_status_5ee33bf3cb92f` ON `_field_booking_status_5ee33bf3cb92f`.`pages_id` = `pages`.`id` WHERE (pages.templates_id=53) AND (pages.status<1024) GROUP BY pages.id ) AS `join_booking_status_5ee33bf3cbbbe` ON `join_booking_status_5ee33bf3cbbbe`.`id` = `_field_booking_status_5ee33bf3cb92f`.`data` WHERE (pages.templates_id=53) AND (pages.status<1024) GROUP BY pages.id " (1933) in .../RockFinder3/RockFinder3.module.php:504 I can add any field in the "template=booking" statement EXCEPT 'title'. Using 'addRelationship' is even worse. It errors with PHP out-of-memory. Using RF3 v1.0.7 and PW 3.0.158 Help appreciated.
  4. Thanks for liking @bernhard Another tip... not only doesn't it work, but who wants multiple CSS files for a repeater? In this scenario, the page template had another RM2 field - simple field on the main template. All CSS for the repeater RM2 field went into the other RM2 field's CSS file, not the repeater field's CSS. I'm sure there are other ways to get the RM2-in-a-repeater's CSS to work - just needs thinking outside the square ?
  5. I realise this module is deprecated but it is in use on a site I'm working on. I needed to add a RM2 field into a repeater and it didn't work due to the unique nature of repeaters. A little hack to RM2 Inputfield module solved 2 problems at once. The Inputfield works in repeaters AND the repeater item ID is accessible in the parent page via the $session var. <?php /** * Set the field content from the file with the same name */ public function ___getContent() { $out = ''; // get file $name = $this->name; /****** hack - breaks on repeater fields ******/ if (strpos($name,'_repeater') !== false) { // it's in a repeater field $ary = explode('_repeater', $name); $name = $ary[0]; // save the repeater item ID with the original fieldname as the key for future use wire('session')->set($name, $ary[1]); } /****** end of hack - breaks on repeater fields ******/ $file = $this->main()->getFile($name); if(!$file) return "No file found for field $name"; // if a value was set return it if($this->value) $out = $this->value; else { // otherwise try to render the file try { // get page object $page = $this->page; if($this->process == 'ProcessPageEdit') { $page = $this->process->getPage(); } // get markup $out = $this->files->render($file->path, [ 'inputfield' => $this, 'rm' => $this->rm, ], [ 'allowedPaths' => [$file->path], ]); } catch (\Throwable $th) { $out = $th->getMessage(); } } return $out; } It's a bit rough but it works for me and maybe this tip can help others working with repeater fields.
  6. @kongondo It's related to RockFinder3. Posted in the wrong place
  7. Love the way @bernhard has integrated PW selectors/way-of-doing-things in RF3. The doco is really good too. Got the basics no problem. I'm sure I'll figure it out eventually but any tips welcome for this scenario: Client hires out equipment and needs to know 'last and next booking date' for an item and ensure that new bookings don't clash. Simplified template structure is: Booking with: - Event date(s) - Booking items (repeater field) that calls on a list (page reference field) of bookable items Report needs to show (filterable): Item (multiple defined template names) Last booking date Next booking date = availability for a given proposed booking event date Any pointers on how I can achieve this RF3?
  8. psy

    Fatal Error

    Please show the code where it falls over... the logs and/or TracyDebugger should help
  9. Not my video - just shared it ?
  10. Hi @bernhard love your work. Is RF2 upgradeable to RF3 or is RF3 a completely different module?
  11. It's fun and wildly different to what I'm used to. It's tight integration with VS Code makes learning much easier. Definitely worth a look
  12. @picarica all good, glad you solved it and no need to apologise ?
  13. @kongondo Have been studying/playing with Flutter and catching up on latest trends in CSS, Photoshop, and other stuff during "all this sh*t" (that's what we in Australia call the pandemic that will never be named). Can't "asynch await" to put new knowledge into action ?
  14. You are looping through the repeater field items (buildings) but not their images (one or many per building) as well. By default an 'images' field can hold multiple images and you simply loop through them. If the only field in your repeater is 'r_galeria_image' then it's unnecessary to have a repeater. foreach ($page->r_galeria_image as $image) { $thumbnail = $image->size(450, 250); echo"<article>"; echo "<a href='{$image->url}' class='fresco' data-fresco-caption='{$image->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo"</article>"; }
  15. @shogun This module may help or provide a good starting point: https://modules.processwire.com/modules/admin-restrict-page-tree/
  16. @JoshoB In my case the user is already logged in on the Front End, but you could test with an $input->get var: <?php $vars = ['page'=> $yourPageObject]; $out = $files->render('your-template', $vars); echo $out; exit();
  17. @Robin S Thank you! So many options and as said to Bernhard, will explore when I have time. Right now RockMarkup2 is doing the job with FB and elsewhere in the project. Will replace when the pressure is off
  18. Thanks @bernhard, after looking at your RockMarkup2 and Adrian's RuntimeOnly modules + your tutorials, am sure I could figure it out. For this project however, I'm under the gun with a rapidly approaching deadline. Will explore creating my own module when the pressure is off.
  19. Thanks @adrian @Robin S's module is simple and sweet. Sadly cannot use in FormBuilder as it has both the Inputfield class and the Fieldtype class within the FieldtypeRuntimeOnly.module file. FormBuilder looks for module files prefixed with 'Inputfield' in its list of approved input types. I use @bernhard's module 'RockMarkup2' elsewhere in the project and only discovered that it's designed to only work in admin and it's been deprecated. However, just tried it in FormBuilder and it works a treat. Maybe Robin and Bernhard can get together to come up with an easy to use module that has separate files for Fieldtype & Inputfield. That would be awesome!
  20. Encountered this issue too. The following change to InputfieldRuntimeMarkup appears to have fixed the missing utilities class: <?php public function init() { // parent::init(); // get the helper class (included in FieldtypeRuntimeMarkup.module file) $this->classLoader->loadClass('FieldtypeRuntimeMarkup'); // add this line to ensure the RuntimeMarkupUtilities class is available $this->rtmUtilities = new RuntimeMarkupUtilities(); } Can now install, uninstall, create & delete fields, etc without problems. I needed this module for a FormBuilder form but sadly the module's configurable fields aren't available in FormBuilder ?
  21. Yep, that's a solution - 20yrs ago HTML/CSS ? In my particular case there are other factors. The user can choose to include/exclude bits which makes it an ugly, logistical nightmare.
  22. Hi @bernhard Yes, RockLESS, SCSS and other CSS preprocessors can be useful. One thing I learned the hard way however is that the header is loaded before any HTML or CSS. The only way I could style the header to look as intended was with inline styles. I certainly used classes with the limited CSS styling available from mPDF in the body. Maybe there's a better way, just didn't have the time or patience to explore. Another limitation was with tables... I needed a centered heading and left aligned text within a table cell. Nope, if the <td> is left aligned, so is everything within the cell. Had to revert to divs which had an impact on the design. Told the graphic designer to live with it - it is what it is! LOL Having said that, love your module and mPDF, even with its constraints, is still the best HTML to PDF converter.
  23. @bernhard Oh so true! Pdf's can look different between browser views and Acrobat Reader too.
  24. Thanks for another great module @bernhard Wanted to share my experiences changing from Pages2PDF to RockPdf. Wasn't quite as straightforward as I'd hoped. Such is life, but I got there. Pages2Pdf uses mPDFv5+ while RockPdf uses mPDFv7+ and I needed some of the newer features. Things Iearned along the way: 1. If you need to use @page, you lose everything in the template $pdf->set('header', '...'); settings. This has nothing to do with RockPdf but a 'feature' of mPDF 2. It's much easier to add custom fonts to RockPdf than Pages2PDF 3. You can display images in a circle using background-image but they don't print so that's not helpful, LOL This is NOT a full tutorial but hopefully will give you some pointers on how I got RockPdf working for a fairly specific PDF design. RockPdf template settings: <?php $pdf = $modules->get('RockPdf'); $pdf->settings([ 'fontdata' => (new \Mpdf\Config\FontVariables())->getDefaults()['fontdata'] + [ "montserrat" => [ 'R' => "montserrat-regular.ttf", 'B' => "montserrat-bold.ttf", ], "montserratlight" =>[ 'R' => "montserrat-light.ttf" ], "montserratthin" => [ 'R' => "montserrat-thin.ttf" ] ], 'defaultheaderline' => 0, 'font_size' => 9, 'mode' => 'utf-8', 'font' => 'montserrat', 'page_format' => 'A4', ]); $css = wireRenderFile($config->paths->templates . 'RockPdf/styles-v3.css'); $pdf->write("<style>" . $css . "</style>"); $body = wireRenderFile($config->paths->templates . 'RockPdf/profile_pdf_cv-v3.php'); $pdf->write($body); $pdfFile = $sanitizer->pageName($profile->title) . "-" . $profile->id . ".pdf"; $pdf->show($pdfFile); die(); // Remove old Pages2PDF settings // $mpdf->markupMain = $config->paths->templates . 'RockPdf/profile_pdf_cv-v3.php'; // $mpdf->markupHeader = $config->paths->templates . 'RockPdf/_header-v3.php'; // $mpdf->markupFooter = $config->paths->templates . 'pages2pdf/_footer-v2.php'; // $mpdf->cssFile = $config->paths->templates . 'RockPdf/styles-v3.css'; // $mpdf->pageOrientation = 'P'; // $mpdf->pageFormat = 'A4'; // $mpdf->topMargin = 9.5; // $mpdf->rightMargin = 0; // $mpdf->bottomMargin = 9; // $mpdf->leftMargin = 0; // $mpdf->headerMargin = 0; // $mpdf->footerMargin = 0; // $mpdf->fontSize = 9; // $mpdf->mode = 's'; // $mpdf->font = 'montserrat'; Header code: <div style=" background-color: #007ee5; height: 10mm; margin: 0; top: 0; left: 0; right: 0; width: 100%; "> </div> Page layout code: <?php // header is the same on all pages but need more spacing on all pages except the first $header = wireRenderFile($config->paths->templates . 'RockPdf/_header-v3.php'); ?> <htmlpageheader name="myHeaderFirst" style="display:none"> <?=$header?> </htmlpageheader> <htmlpageheader name="myHeader" style="display:none"> <?=$header?> </htmlpageheader> <sethtmlpageheader name="myHeaderFirst" value="on" show-this-page="1" /> <sethtmlpageheader name="myHeader" value="on" /> <div class="user-dets"> CSS: /* Additional fonts added to: site/assets/RockPdf/fonts */ @page { margin: 15mm 0 0 0; /* <any of the usual CSS values for margins> */ /*(% of page-box width for LR, of height for TB) */ margin-header: 0; /* <any of the usual CSS values for margins> */ margin-footer: 9mm; /* <any of the usual CSS values for margins> */ marks: none;/*crop | cross | none*/ header: html_myHeader; } @page :first { margin: 9.5mm 0 0 0; /* <any of the usual CSS values for margins> */ /*(% of page-box width for LR, of height for TB) */ margin-header: 0; /* <any of the usual CSS values for margins> */ margin-footer: 9mm; /* <any of the usual CSS values for margins> */ marks: none;/*crop | cross | none*/ header: html_myHeaderFirst; } Hope this is useful. Cheers psy
  25. Hi @Jozsef The module defines a special fieldtype of FieldtypePushAlert - this generates the message title, content etc sub-fields in the template for the push notification. It's used in various ways under the hood to send and gather/display stats about the notification. So, no, you can't use the existing title, headline, summary fields with this module.
×
×
  • Create New...