1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

SOLVED: Help with Custom/Print Template - arrrgggghhh

Discussion in 'Professional Support' started by bggann, Jul 31, 2018.

  1. bggann

    bggann Member

    Level: Community
    Just created a custom template that displays just the "calculations" row from a grouped list.
    This is a special formatted display for reports to vendors. I do not need to display the group records, just the totals.

    Got it working in list display.

    Hit print - and the print is formatted based on the PDF template for the list, not the template in the menu. ARGGHH - that means all my custom template work is not useful because I must be able to print from this.

    I can change the pdf template for the 'list', but then I can't print normal list displays.

    Is there anyway to override the print/pdf template from a menu.

    I suppose I can "copy" the list and create a second list that has the other template, but in my experience, that turns into a mess with large lists that have lots of elements.

    Suggestions?

    Bob
     
  2. bggann

    bggann Member

    Level: Community
    I'm still trying to work around this - and I'm confused by the "print/PDF" Icon (see attached first capture/image). On my forms I see "print, email and pdf" icons. The Print creates a window with a 'print' rendering. PDF downloads a pdf.

    On my list display - all that shows is print button - can't find anyplace to show the PDF button (see 2nd capture/image). Not sure it would help, but maybe....
    I need to be able to select a different template for printing based upon the report (ideally, it would be in the menu).

    This is what is on the form.
    View attachment 17431

    This is what is on the list display.
    View attachment 17432
     
  3. troester

    troester Well-Known Member Staff Member

    Level: Community
    In the list there's only a PDF button, no Print button.

    You can override the PDF template by adding &pdf_template=your-template to the URL.

    If you are running a recent GitHub version (not sure if it's already in the official Fabrik3.8.1) you have a list menu option "Extra Query String".
    If you want to override the PDF template for one menu item add there
    &pdf_template=your-template
     
  4. bggann

    bggann Member

    Level: Community
    Thanks Troester... It's weird that my list shows "Print" instead of pdf, but the behavior is pdf. I am running 3.8.1, not GitHub and I'm very careful to upgrade this site as it is actively used by our firefighting operations.

    I do not see any "Extra Query String" in the menu options, so that must be in the Git, not the released version.

    So- it looks like I'll have to use a menu link that is not the normal Fabrik/List Menu item, but a System/External URL menu link to add this to the URL. I see no way to add this to the URL created by the Fabrik/List menu item without that extra query string option- am I correct in that.

    That will solve my problem. Thanks!
    I'll let you know how it goes.

    -Bob
     
  5. troester

    troester Well-Known Member Staff Member

    Level: Community
  6. bggann

    bggann Member

    Level: Community
    The &pdf_template= function in the URL does appear to work in 3.8.1 - if I add it to the URL generated by the print button, it creates a pdf using my new template.
    BUT - that doesn't really solve my problem.

    I have no way to insert that &pdf_template into the print URL that I know of. I can't create a custom menu link to the list because the list is filtered for an aircraft and date range, then grouped, all before the PRINT is done. The filters used vary so I have no way to anticipate what filtering to do before the print.

    So - while the extra query part seems like it would work - I don't have it on 3.8.1 and upgrading to an unreleased (Github) is pretty scary for this site.

    This is an operational firefighting site - and we are on fire here, so the site must stay up.

    -- Any way I can customize the print button (yes, that would be a non-upgradable patch, but I'm willing to do that).

    Bob
     
  7. troester

    troester Well-Known Member Staff Member

    Level: Community
    If the &pdf_template is working (seems the 3.8.1 release has been created a bit after the GitHub tag) you can create a custom list template (you have already created the PDF template so I assume you know how to) and modify default_buttons.php.

    Around line 108 change
    <li><a href="<?php echo $this->pdfLink;?>" class="pdfButton">
    to
    Edited:

    <li><a href="<?php echo $this->pdfLink . '&pdf_template=your-PDF-template';?>" class="pdfButton">
     
    Last edited: Aug 1, 2018
  8. bggann

    bggann Member

    Level: Community
    Fantastic. Yes, I do know how to create a custom template and I remember seeing the default_buttons file. Why it didn't occur to me that I could custmize the PDF button there....
     
  9. troester

    troester Well-Known Member Staff Member

    Level: Community
    default_buttons.php is very useful.
    You can also add multiple PDF buttons with different templates, different CSV exports etc.
     
  10. bggann

    bggann Member

    Level: Community
    Worked like a charm. I assume you meant &pdf_template=
    not &pdf_element= in your reply - so that is what I did.
    I also used this file to suppress the toggle button since toggling messes up my collapsed template.

    I put in...
    <li><a href="<?php echo $this->pdfLink . '&pdf_template=your-PDF-template';?>" class="pdfButton">
     
  11. troester

    troester Well-Known Member Staff Member

    Level: Community
    Yup:) (I've now corrected it in the original post)
     

Share This Page