Jump to content

psy

Members
  • Posts

    741
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by psy

  1. 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.

     

     

     

  2. 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 ? 

     

  3. 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.

     

     

    • Thanks 1
  4. 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?

    • Like 1
  5. @kongondo

    3 hours ago, kongondo said:

    An alternative you could consider, if you have the time and want to pick up a new skill is to create your android app using Flutter ?

    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 ?

    • Like 2
  6. 28 minutes ago, picarica said:

    $thumbnail = $building->r_galeria_image->size(450, 250);

    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>";
        }

     

    • Like 2
  7. 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! 

  8. On 3/27/2020 at 2:42 AM, kongondo said:

    Sorry all, I haven't yet found time to act on this. I need time to investigate it properly.

    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 ?

    • Like 1
  9. On 4/22/2020 at 10:18 PM, bernhard said:

    Writing your styles as LESS can be helpful because you can create simple custom classes for any element and to the complex styling in CSS.

    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.

     

    • Like 2
  10. 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

     

    • Like 3
    • Thanks 1
  11. 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.

  12. I used Canvas HTML theme which overlaid Bootstrap then added my own customisations which often overrode the Canvas theme CSS which overrode Bootstrap. The code bloat was stupid.

    Going back to pure SCSS/CSS with smarter use of CSS Grid, Flex & media queries. Can now place things where I want depending on screen size/device without unnecessary HTML for purely structural purposes, eg floated divs etc and much less CSS download. The page file size difference is incredible.

    Also trying to wean self off jQuery. That may take a little longer especially as PW is so dependent on it.

    • Like 3
  13. [SOLVED]

    I've used this module in the past and it's been great but now I'm having problems.

    Scenario

    • Page to output as PDF is different to current page so included link in the template as per instructions
    • Created template in pages2pdf/ templates dir with same name as page template
    • Configured module to use header & footer
    • Set Cache time to 1 to minimise caching while testing
    • Configured Creation Mode to "On click..." as there is no need to store the PDF's on the server

    All good so far. Just needed to tweak the topMargin to that the header didn't overlap the main content. That's where I got into trouble.

    To eliminate any caching issues, I change $config->debug to true and this was the result:

    Spoiler

     

    
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; mPDF has a deprecated constructor in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/mpdf.php on line 66
    
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; grad has a deprecated constructor in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/grad.php on line 3
    
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; form has a deprecated constructor in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/form.php on line 3
    
    Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; cssmgr has a deprecated constructor in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 3
    
    Warning: Illegal string offset 'ID' in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1126
    
    Warning: Cannot assign an empty string to a string offset in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1126
    
    Warning: Illegal string offset 'ID' in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1202
    
    Warning: Illegal string offset 'ID' in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1206
    
    Warning: Illegal string offset 'ID' in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1406
    
    Warning: Illegal string offset 'ID' in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1410
    
    Warning: Illegal string offset 'ID' in /home2/wiserhir/public_html/site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 1126

     

     

     

    It went on with a lot of garbage and nothing was downloaded.

    Switched $config->debug back to false and at least got the download happening.

    I need to increase the size of the header so it doesn't overlap the main content. Read the doco and tried to implement the recommendations in every place possible without success.

    Question:

    How do I change the top margin without hacking the default "30" in the module?

    Using PW v3.0.148 and Pages2PDF v1.1.7

    Solution:

    WirePDF requires the pdf to be saved in order to apply any config changes such as the top margin.

     

     

     

×
×
  • Create New...