Change file name

Status
Not open for further replies.

csantof

Member
Hello,

How can I change the PDF file name ?

I have created a form with :
id
first name
last name
etc etc
the name of the PDF file is "nameform - id.pdf". I need last name.pdf

thanks for your help
 
You can override the layout that builds the filename.

See the wiki for details on how to override layouts. Short version:

Copy

./components/com_fabrik/layouts/form/fabrik-pdf-title.php

... to ...

./templates/<your site template>/html/com_fabrik/layouts/form/fabrik-pdf-title.php

Then customize to do two things ... first you have to check to see if the form being rendered is the one you want to change the filename for, then you need to assemble the name.

Code:
<?php
/**
 * PDF document title for form view
 *
 */

defined('JPATH_BASE') or die;

$d = $displayData;

/**
 * Set the download file name based on the document title and rowid
 *
 * For overriding, you can access form data in $d->model->data['yourtable____yourelement'];
 *
 */

// replace '123' with the numeric ID of your form
if ($d->model->getId() == '123') {
  // replace yourtable___last_name with the full element name from your form
   echo $d->model->data['yourtable___last_name'];
}
else {
   echo $d->doc->getTitle() . '-' . $d->model->getRowId();
}
 
Note, if you update from github to pick up this change:

https://github.com/Fabrik/fabrik/commit/6e51bc86b6686abe82cfb78623cc6d008e3405be

... you can override that layout on a per Fabrik template basis. Which is useful if you already use a custom details template for you PDF, you don't have to worry about making sure you are being called for the right form. Just copy the file to ...

./components/views/details/tmpl/<your custom template>/layouts/form/fabrik-pdf-title.php

... and do ...

Code:
<?php
/**
 * PDF document title for form view
 *
 */

defined('JPATH_BASE') or die;

$d = $displayData;

/**
 * Set the download file name based on the document title and rowid
 *
 * For overriding, you can access form data in $d->model->data['yourtable____yourelement'];
 *
 */

echo $d->model->data['yourtable___last_name'];


NOTE - whichever override location you use, you'll probably have to create some of the folders, unless you've already added any layout overrides.

-- hugh
 
Ok, it's good, but not with the substitution I had to modify the original file manufactk-pdf-title.php in the original directory and now it works well
 
The override does work, I tested it before answering. You need to use an override, otherwise your changes will get overwritten next time you update.

-- hugh
 
Hi,

I wanted to use the own system to joomla to create my override, but I do not see the layouts in the list. So I created the tree by hand as you told me but it does not work.
 
Ok, I used the second solution with the github update and replacement in my personal PDF template and everything works fine, that's good.

Now I have another problem that I posted in another thread. If you can help Troester and I find a solution it would be very cool.

The name of the thread is Problem with PDF template. All works except my logo.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top