The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Smarty Templating - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8) +--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16) +--- Thread: Smarty Templating (/showthread.php?tid=151) |
Smarty Templating - stevenheidel - May 13th, 2009 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) RE: Smarty Templating - Ben - May 13th, 2009 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=""} 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 RE: Smarty Templating - stevenheidel - Jun 24th, 2009 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 ![]() *** 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! RE: Smarty Templating - Ben - Jun 26th, 2009 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 |