Load detail templete (pdf) from template sub folder?

Status
Not open for further replies.

deant

Active Member
Hello,

We have an existing template for printing out the form. Let's say we use a different template from now on. However, for entries before a certain date, we need to use the old template.

I have to say that the template is quite demanding, it also contains two repeatable gropus. I have 10 different files - each page has its own file.

I was thinking it would be best to do a sub folder for each version. So from details/myTemplate/default.php I would call which template to load but I dont know how to do.

Any clue...txh
 
Stick with the Fabrik template structure as it is. That way you can easily add and maintain custom templates for all sorts of uses, including the one you need - as described here:

What a user gets to see after submitting a form can be set in Redirect Form Plugins: http://fabrikar.com/forums/index.php?wiki/redirect-form-plugin/
You can have multiple such plugins, differing in condition (in the field of the same name) and jump page.

The jump page URL may include a "layout=myTemplate" query which, if it's a Fabrik view, will load it in "myTemplate" style.
 
Lousyfool thanks for your reply but redirect plugin is not what I need/want --> The redirect plug-in allows you to decide where the browser should be redirected to at the end of the form submission.

I set up custom detail url in List so I can open pdf reports directly from table.
 
Well, sorry, you were referring to "details" and "printing out the form". So, along with your other indications, I understood that you want to display details (= form data) in various ways, indeed after submitting the form.

Sorry again, at least I got you wrong. Perhaps you could explain users' workflow and what exactly you need when and where, as I'm not sure if or how your line here above is related to the problem:
I set up custom detail url in List so I can open pdf reports directly from table.
 
I set up custom detail url in List so I can open pdf reports directly from table.
So something like
index.php?option=com_fabrik&view=details&formid=1&rowid=5&format=pdf&Itemid=111&lang=de ?

As @lousyfool said you can add &layout=myTemplate to such a link.

If you need it depending in a complex way on record data (so you can't use a placeholder) you can use a calc element to compose the link you need and use this in your list view.
So something like
if (it's an old record) $myTemplate = 'templateold';
else $myTemplate = 'templatenew';
return 'some-link&layout='.$myTemlate;
 
Sorry, English is not my native so I expressed myself incorrectly.

In my case, I have to provide reports as they looked on the day of creation. Otherwise, the user would have to save the report somewhere...

Very short example: Right now let's say we have 3 input fields. We sent the client a report with these three items. A year later we added in our form another input field. We created a new template with 4 input fields.
Year latter we cant print an old report with 3 input fields because we have a template with 4 input fields. We need a report with 3 input fields. Right?

Anyway I was able to find a solution:

In Detail/MyTemplete I changed default.php to

PHP:
defined('_JEXEC') or die('Restricted access');

$form = $this->form;
$model = $this->getModel();  

$condition_element = $this->groups['group_name']->elements['element_name']->element;  // can use ->value 

if ($condition_element = 'true') {
    require_once JPATH_SITE . '/components/com_fabrik/views/details/tmpl/your_templete/subfolder_1/filename.php'; 
}
else { require_once JPATH_SITE . '/components/com_fabrik/views/details/tmpl/your_templete/subfolder_2/filename.php';
}

/* end file */

Again this is for custom templete...if you use Fabrik default template it wont work.

Have fun and stay well
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top