FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Export Manager: Custom Table View
#1
My goal: To create a HTML/Print view with a custom table, similar to how I can customize the email body. I have an employment application that is very long. When properly formatted in html, I can display the questions and answers in a manner that resembles your typical application.

My problem: Smarty templates. I simply don't understand the logic enough to customize the templates.

Can someone point me in the right direction, or even provide an example of a custom smarty template? Any help is greatly appreciated.

Oh, and Ben... This tool rocks!
Reply
#2
Hi Heywood,

Thanks! The script is coming along... and boy, once the Form Builder module is released (soon next month), I think it'll go a looooong way to simplifying things for people. We're pretty excited about that on our ends.

So... Smarty templates. Yeah, it takes a little work to make sense of how they work.

Do any of the existing HTML/Printer-friendly options somewhat resemble what you're trying to do? That would be a good place to start: make a copy of one of the Export Types and start playing around with that.

Also, is is the style, or the formatting of the content that you're trying to change, exactly?

- Ben
Reply
#3
(Dec 31st, 2011, 12:24 PM)Ben Wrote: Do any of the existing HTML/Printer-friendly options somewhat resemble what you're trying to do? That would be a good place to start: make a copy of one of the Export Types and start playing around with that.

The One-by-one option is the closest, formatting-wise.
   

However, this screenshot of the email I receive has the ideal formatting. I would like to replicate this look.
   
Reply
#4
I'm so sorry for the long response time. I'm just trying to wrap up some work before I leave the country at the end of this month, and everything else is falling by the wayside.

When I first read your post I thought "no problem!" but when I just tried putting together a working example today, I was surprised how tricky it was - not just tricky, actually: downright complicated! The default Smarty content in the Export Manager code is really too complex by half. I'll have to simplify it in future versions.

So what I ended up doing was writing a helper Smarty function that *significantly* simplifies the job for us. I'll include this in the next version of the module for anyone in a similar situation.

Anyway, here's how to get it all done.

First off, since you need such a specific format, start by piecing together the HTML that you need for a *single* outputted submission. Just leave blank spaces where you want the values to be outputted from the database. Your HTML would just contain the main table layout and labels. When I look at your desired output, it'll clearly take some fiddling just to get the markup right with all the appropriate rowspans / colspans etc.

Once that's ready, it's a matter of putting it into the Smarty template and pasting in the appropriate variable into each spot in the field.

Download the attached file and upload it to your [form tools]/modules/export_manager/smarty/ folder. After it's been added there, it will be available to be used in your own Export Types Smarty content that you enter in the Export Manager module.

Here's a simple example of how it works. Instead of the loop-within-loop that the default HTML / Printer-Friendly "Table Format" Export Type smarty content uses (which is complicated, but fast), this works differently. It loops through each submission, but display explicit field values based on their column names. So, you just pass in the unique database column name for the field, and it will output the appropriate value for the current submission at the spot.

Code:
{foreach from=$submissions item=submission}

  
  <table>
    <tr>
      <th>Submission ID:</th>
      <td>{display_field_by_colname col_name="submission_id"}</td>
      <th>Field #1</th>
      <td>{display_field_by_colname col_name="col_1"}</td>
    </tr>
    </table>

    <br />

{/foreach}

In my case, I have a field called "Field #1", which has a column name of "col_1".

What you need to do is copy your markup into the Smarty Export Type content field and replace the <table> in the example above. Then, any place you want a value outputted for a field, just call the function, specifying the field you want:

{display_field_by_colname col_name="XXXXXX"}

And that's pretty much it!

Let me know how it goes.

- Ben


Attached Files
.php   function.display_field_by_colname.php (Size: 1.78 KB / Downloads: 56)
Reply
#5
Ben - this post was most helpful and I was able to modify it to fit my similar needs.

However, my problem is that although the view/report looks perfect in the popup window, my inline CSS in my table is discarded when I print. Any way to prevent this?

UPDATE - this was solved by simply setting a fixed height for the table. Changed from 100% to 400px
Reply
#6
thankyou mr. Ben, this is also solve my problem, but how if we want put image (view), in that export layout? because it is just appear the link, and if i put <img src=...> there is a hyperlink code inside..

sorry for may bad English, would you can solve my problem
Reply
#7
(Sep 10th, 2012, 2:55 PM)dedy Wrote: thankyou mr. Ben, this is also solve my problem, but how if we want put image (view), in that export layout? because it is just appear the link, and if i put <img src=...> there is a hyperlink code inside..

sorry for may bad English, would you can solve my problem

Hi Same question here -- how do I override the automatic linking of files (the addition of the <a href="") so that I can display an image?
Reply
#8
(Jan 8th, 2012, 1:33 PM)Ben Wrote: I'm so sorry for the long response time. I'm just trying to wrap up some work before I leave the country at the end of this month, and everything else is falling by the wayside.

When I first read your post I thought "no problem!" but when I just tried putting together a working example today, I was surprised how tricky it was - not just tricky, actually: downright complicated! The default Smarty content in the Export Manager code is really too complex by half. I'll have to simplify it in future versions.

So what I ended up doing was writing a helper Smarty function that *significantly* simplifies the job for us. I'll include this in the next version of the module for anyone in a similar situation.

Anyway, here's how to get it all done.

First off, since you need such a specific format, start by piecing together the HTML that you need for a *single* outputted submission. Just leave blank spaces where you want the values to be outputted from the database. Your HTML would just contain the main table layout and labels. When I look at your desired output, it'll clearly take some fiddling just to get the markup right with all the appropriate rowspans / colspans etc.

Once that's ready, it's a matter of putting it into the Smarty template and pasting in the appropriate variable into each spot in the field.

Download the attached file and upload it to your [form tools]/modules/export_manager/smarty/ folder. After it's been added there, it will be available to be used in your own Export Types Smarty content that you enter in the Export Manager module.

Here's a simple example of how it works. Instead of the loop-within-loop that the default HTML / Printer-Friendly "Table Format" Export Type smarty content uses (which is complicated, but fast), this works differently. It loops through each submission, but display explicit field values based on their column names. So, you just pass in the unique database column name for the field, and it will output the appropriate value for the current submission at the spot.

Code:
{foreach from=$submissions item=submission}

 
 <table>
   <tr>
     <th>Submission ID:</th>
     <td>{display_field_by_colname col_name="submission_id"}</td>
     <th>Field #1</th>
     <td>{display_field_by_colname col_name="col_1"}</td>
   </tr>
   </table>

   <br />

{/foreach}

In my case, I have a field called "Field #1", which has a column name of "col_1".

What you need to do is copy your markup into the Smarty Export Type content field and replace the <table> in the example above. Then, any place you want a value outputted for a field, just call the function, specifying the field you want:

{display_field_by_colname col_name="XXXXXX"}

And that's pretty much it!

Let me know how it goes.

- Ben

Ben this has stopped working when I updated to FormTools 3.0.1 and Export Manager 3.0.5.  Are there any plans to update the script?

Thanks!

Paul
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)