• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Hide element in pdf

Status
Not open for further replies.
Hi, I need to hide some elements only in the pdf output when the content equals certain text, how can I do that?
For example, when I select the text "hide" in a dropdown element I need that element would be ignored in the pdf.
 
First you have to create a custom template, copy the templates folder and rename it. How to do it read here.

Maybe you can add some jQuery to change element style if condition is true. - I did not try but it should be work.
or
if you familiar with PHP, HTML and CSS you can create custum tempalte from scratch. It is not too hard ;)
 
thank you, I am a newbei and I had try with default.php but I can't understand how call and manage a single element
$this->elements = $group->elements;
echo $this->loadTemplate($group->tmpl);

can you help me?
 
Well, my pdf templats are usually a form with a specific content and format. I include only those elements in the template that I show in the printout, I omit the other elements.

All you need is to chenge defalut.php to something like I described in this post

Of course this is not the ene and only way to create pdf template but it is easy and works fine for me. Just search this forum...you can find a lot usfull tips, hints and code examples.
 
ok, now I know how to create a custom template but this code not work, DIV does not hide in pdf template :(

<?php
$element = $this->groups['group1']->elements['element1'];
?>
<div <?php if ($element->element == '-') echo " class='display-none';"; ?>>
<?php echo $element->element;?>
</div>
 
In Fabrik Options/Debugging set Debug PDF=yes.
This will display the generated HTML (which is otherwise used for creating the PDF) on your screen and you can inspect with your browser console what you get.

Additionally your can var_dump($element) to see if $element->element is really '-' . Depending on your element type and settings it may be also e.g. a link. Maybe you need to use $element->element_raw ...

BTW: If you don't want to display the element you can just skip it instead of hiding via CSS.
 
The output is really "-".
I can't do it via CSS because I need to hide elements only if the content is "-".
It is selected time after time in the form (dropdown menu).
 
I get "-"
I tried to change the value with another word but the result Is the same
Maybe I have to call the element in a different way...
 
Do you get class='display:none;'?
Is it hidden on the screen?
A displayed "-" may also be a <a...>-</a> or include a non-printable character or some other HTML tag...
 
No, nothing more then -
I'm try to verify the output element and the condition but it doesn't works
<?php if ($element->element == '-') echo $element->element; else echo 'DIFFERENT' ?>
It shows "DIFFERENT" every time
 
Obviously ($element->element == '-') is false.
Did you try to var_dump?
Did you inspect your page source code?
 
string(99)
So it's obviously not only '-' but 98 additional characters.
As I said:
Additionally your can var_dump($element) to see if $element->element is really '-' . Depending on your element type and settings it may be also e.g. a link. Maybe you need to use $element->element_raw ...
 
Please read the answers before posting
Depending on your element type and settings it may be also e.g. a link. Maybe you need to use $element->element_raw ...
 
carfully read again what troester wrote:

Depending on your element type and settings it may be also e.g. a link. Maybe you need to use $element->element_raw ...

AGAIN -> you can get element value in different ways and is also depending whitch type of element is:

$element = $this->groups['group1']->elements['element1'];
or
$element = $this->groups['group1']->elements['element1_raw']; // raw data
or
$element = $this->groups['group1']->elements['element1_ro']; // read only

For dropdown element I would use element_raw to get value
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top