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
Smarty Templating
#1
Just a couple smarty questions (where I'm using show_submissions on a website):

1. *important and easy* How do you call a specific value from one column? I'm trying to colour code my table so that the colour is based on one of the responses in the form. I've devised a system in my css of styling the <td>'s with different classes, named for the same options from my form. All I need is a smarty command to go here: <td class="{value of one particular field}">

2. *somewhat important but probably difficult* I'd like to have separate tables and headings for each region of my form fillers. One option on my form is region, so I'd like to see the page look like this:

Region 1
Person Email Date
Person Email Date
Person Email Date

Region 2
Person Email Date
Person Email Date
Person Email Date

Is this possible?

Thanks a lot!

(PS Coincidentally, I'm eating smarties right now)
Reply
#2
Hey Steven,

Yes, both are definitely possible, but may take some fiddling.

1. I don't quite follow exactly what you need, I must admit. I get the general gist, but the details escape me. You can't reference a specific value within the variables passed to the template unless you know exactly where the value is (row + column) within the var - which is probably unlikely, since the contents are dependant on the current form, View, search criteria and order.

What you might want to try is looping through the $submission var TWICE - the first time extracting whatever value you want based on your criteria. e.g. this grabs the first value in the "X" column:

Code:
{assign var=my_val value=""}
{foreach from=$submissions item=submission name=row}
    {foreach from=$display_fields item=field name=col_row}
      {assign var=col_name value=$field.col_name}
      {assign var=value value=$submission.$col_name}
      
      {* if this is column X, grab the value *}
      {if $my_val == "" && col_name == "X"}
        {assign var=my_val  value=$value}
      {/if}
    {/foreach}
{/foreach}

{* this outputs the value *}
{$my_val}

2. Depending on your data set, this may be simpler. What you could do is again put multiple loops through the $submissions var, omitting results in each data set that don't match a particular criteria.

Sorry, it's really tricky to give helpful advice on both of these question - this is something that really needs to be played around with directly.

- Ben
Reply
#3
Thanks. I figured it out. After re-reading my original post, I realize why you might have been confused so I sort of disregarded your answer. (Both questions were independent of another, that's why). Anyways, here's how I did it.

1. All I wanted to do was colour code my submissions.

<tr class="{$submission.party}">

And then my CSS just has 10 colours or whatever. That was easy.

2. What I wanted to do was group by a field. After searching on google a bit, I found someone else who did it and copied their code. I then realized it was the exact same method as your code Tongue . Oops. Just looping a variable worked great.

*** Finally, I was wondering... this sounds a little weird but could you have a field sort by the order they are in the dropdown? My groups right now sort alphabetically, but could they sort in the order they are in the dropdown and include empty ones as well? It's not important, I was just wondering.

Thanks again for your continued help!
Reply
#4
Quote:*** Finally, I was wondering... this sounds a little weird but could you have a field sort by the order they are in the dropdown? My groups right now sort alphabetically, but could they sort in the order they are in the dropdown and include empty ones as well? It's not important, I was just wondering.

Good question... hmm. You can do this by changing the values (not the DISPLAY values - just the values) of the dropdown to be alphabetical. Not a great solution, but it should work.

Other than that I'm rather out of ideas!

- Ben
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)