-
Need a little direction with fmcompute.
Will the Computation module help me select different forms based on a selected value?
Example:
<select name="year">
<option value="">Year</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
</select>
<select name="make">
<option value="">Make</option>
<option value="Acura">Accura</option>
<option value="Bmw">Bmw</option>
<option value="Ford">Ford</option>
</select>
So on the second form I would insert the two values from the first page like so.
Then present another drop down for the particular model.
2008
Ford
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
-
Re: Need a little direction with fmcompute.
Few questions.
1) What logic would I use to load_the_proper_makes base on what_model_was_selected?
2) Can this be done with out fmcompute? Is there another way?
3) How can I hide all the important stuff so no one will see/understand the logic?
I am anticipating making a lot forms for each make. Looks like its going to be a lot of work.
Tia
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
Originally Posted by
billy
1) What logic would I use to load_the_proper_makes base on what_model_was_selected?
There are two ways which seem good:- Generate the "next_form" field from a computation so that it selects a different second page (as per your first post) based on the make selected.
- Use the same second page for every make and use Advanced Templates to control what gets displayed.
I think the first method would be easier from a maintenance point of view.
Also, the Advanced Templates don't yet handle expressions in IF blocks - so it makes things more messy.
Here's the basic logic for field "fmcompute1":
Code:
import function FMUserError;
import string make;
export string next_form;
next_form = make.'.html';
This simply appends ".html" to the name of the make to create the name for the next page.
You can do other things like this, depending on what naming scheme you want:
Code:
import function FMUserError;
import string make;
export string next_form;
if (make == 'ford' || make == 'gm')
{
next_form = 'usa/'.make.'.html';
}
else
{
next_form = 'intl/'.make.'.html';
}
So, this is structured for a multiform templates folder that has subfolders called "usa" and "intl" (international). Then the documents for the makes are within one of those subfolders.
Quote:
2) Can this be done with out fmcompute? Is there another way?
It can be done in PHP with FormMail's Hook System - but I don't recommend writing PHP code unless you are a very experienced programmer.
The main worry is creating security vulnerabilities for your server.
The first example logic above is very simple, so you could do it with derive_fields instead:
HTML Code:
<input type="hidden" name="derive_fields" value="next_form=make.%2E%.%'html'%" />
Quote:
3) How can I hide all the important stuff so no one will see/understand the logic?
You can put your fmcompute's in an INI file.
If you have PHP version 4, though, this is impractical because you can't wrap lines in an INI file.
There's an alternative in this case.
Quote:
So on the second form I would insert the two values from the first page like so.
Then present another drop down for the particular model.
2008
Ford
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
Assuming you wanted all makes in the one document, using Advanced Templates, your second page (which is a FormMail template, of course) could look like this (note: this will not work in the current version):
HTML Code:
$year
$make
<if "$make" == "ford"> <!-- this type of expression is not yet supported! -->
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
</if>
As mentioned, that's the idea, but the comparison expression is not yet supported in Advanced Templates....it's coming though.
Instead, you'd have to create a flag field for every type of make (that's why I said it was messy), and the code would need to look like this:
HTML Code:
$year
$make
<if "$make_is_ford">
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
</if>
-
Re: Need a little direction with fmcompute.
Hi Russell,
I have multi now submitting from page 1 to page 2.
Code:
<input type="hidden" name="fmcompute1" value="import function FMUserError;
import string make;
export string next_form;
next_form = make.'.html';" /
The problem is i cannot get the dropdown to load in the second page. I used your example above but does not display.
Code:
$year
$make
<if "$make_is_ford">
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
</if>
I do not understand the correct way to set up the second form to get $make_is_ford to display the dropdown box. It does not show up in the form. When you right click and look at source you dont even see the code for it.
If you would like ftp it is no problem at all...
-
Re: Need a little direction with fmcompute.
Good morning,
I did get the second page working last night. I just went back to a regular select box without the if statements.
HTML Code:
$year
$make
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
However I would still like you to explain about your example below.
HTML Code:
<if "$make_is_ford">
Where was this going. How can I to use this?
-
Re: Need a little direction with fmcompute.
Based on what I have learned in your first post. I need to make things a bit more complicated to me. lol
As i am sure you know with each model year a manufacture produces different vehicles. Meaning they add new kinds of cars and stops making the old ones. I need to account for this in my forms. It means making close to 1000 forms i am sure. What I need is the logic to pull this off in the most none confusing way. lol
In this next step I need to get fm pulling the correct template based on year and make.
Example page 1
HTML Code:
<select name="year">
<option value="">Year</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
</select>
<select name="make">
<option value="">Make</option>
<option value="Acura">Accura</option>
<option value="Bmw">Bmw</option>
<option value="Ford">Ford</option>
</select>
Example page 2
If I chose 2009 Toyota the second page will display.
HTML Code:
<select name="model">
<option value="">Model</option>
<option value="camry">Camry</option>
<option value="corolla">Corolla</option>
<option value="yaris">Yaris</option>
Here is the the basic issue. In the above example
for the model year 2009 they made those three cars
but in the model year 2008 they made different cars
So I chose 2008 and toyota and I have different cars
on the second page than was on the 2009 page.
God I hope that makes sense to you.
So could you provide a few examples in fmcompute for me as well as derive_fields?
This really is very cool stuff man! I think I might be hooked.
Thank you for your time.
Regards
-
Re: Need a little direction with fmcompute.
Hi,
OK, to set a make "test" field you'd do this in an fmcompute:
HTML Code:
import string make;
import string year;
export string make_is_ford;
export string make_is_toyota;
export string year2009;
if (make == 'ford')
{
make_is_ford = '1';
}
elseif (make == 'toyota')
{
make_is_toyota = '1';
}
if (year == 2009)
{
year2009 = '1';
}
and so on.
Then, in your template you'd do this:
HTML Code:
<if "$make_is_ford">
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
</select>
</if>
<if "$make_is_toyota">
<select name="model">
<option value="">Model</option>
<option value="camry">Camry</option>
<option value="corolla">Corolla</option>
<option value="yaris">Yaris</option>
<if "$year2009">
<option value="xymagic">XYMagic</option>
</if>
</select>
</if>
(I'm inventing a new model for 2009 called the "XYMagic".)
You get the idea?
This is a bit clunky because you have to create these extra fields to test for different values.
-
Re: Need a little direction with fmcompute.
Quote:
You get the idea?
This is a bit clunky because you have to create these extra fields to test for different values.
I kinda get it Russell.
This is what I have so far but its still incomplete. I have not been able to figure out how to get it setup correctly.
Code:
<input type="hidden" name="fmcompute1" value="import function FMUserError;
import string make;
import string year;
export string make_is_ford;
export string make_is_toyota;
export string year2009;
export string year2008;
export string year2007;
if (make == 'ford')
{
make_is_ford = '1';
}
elseif (make == 'toyota')
{
make_is_toyota = '1';
}
if (year == 2009)
{
year2009 = '1';
}
if (year == 2008)
{
year2008 = '1';
}
if (year == 2007)
{
year2007 = '1';
}
export string next_form;
next_form = make.'.html';" />
As you can see above by my example I am confused in the correct way to get this working. I am not even sure if I am close to what you intended. The point is I am trying hard to understand your posts.
HTML Code:
<if "$make_is_ford">
<select name="model">
<option value="">Model</option>
<option value="explorer">Explorer</option>
<option value="mustang">Mustang</option>
<option value="taurus">Taurus</option>
<if "$year2009">
<option value="explorer">Explorer</option>
<option value="van">Van</option>
<option value="taurus">Taurus</option>
</if>
<if "$year2008">
<option value="explorer">Explorer</option>
<option value="truck">Truck</option>
<option value="taurus">Taurus</option>
</if>
<if "$year2007">
<option value="explorer">Explorer</option>
<option value="car">car</option>
<option value="taurus">Taurus</option>
</if>
</select>
</if>
<if "$make_is_toyota">
<select name="model">
<option value="">Model</option>
<option value="camry">Camry</option>
<option value="corolla">Corolla</option>
<option value="yaris">Yaris</option>
<if "$year2009">
<option value="">Model</option>
<option value="camry">Camry</option>
<option value="van">Van</option>
<option value="yaris">Yaris</option>
</if>
<if "$year2008">
<option value="">Model</option>
<option value="camry">Camry</option>
<option value="truck">Truck</option>
<option value="yaris">Yaris</option>
</if>
<if "$year2007">
<option value="">Model</option>
<option value="camry">Camry</option>
<option value="car">car</option>
<option value="yaris">Yaris</option>
</if>
</select>
</if>
I understand where you were going with all the different models by year.
Very cool example indeed that seems very straight forward. But i am still puzzled on how to get this talking to fmcompute or fmcompute to this example.
How close am I to getting this puppy working?
-
Re: Need a little direction with fmcompute.
Quote:
Originally Posted by
russellr
Hi,
You can put your fmcompute's in an INI file.
If you have PHP version 4, though, this is impractical because you can't wrap lines in an INI file.
I have php 5.2.6 installed.
I have not been able to hide your first fmcompute1 in my ini file. Any pointers on getting this to work? I have tried every way I can think of.
-----
The following error occurred in FormMail :
fmcompute_parse
**********
Error=These parse errors occurred in the following code:
Line 1, position 1: Undeclared identifier 'make'.
1:make
-----
The following error occurred in FormMail :
fmcompute_parse
**********
Error=These parse errors occurred in the following code:
Line 1, position 1: 'do' is a reserved word or symbol but is not yet supported.
1:do
-----
Hum maybe you can sort this lil issue for me?
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
Originally Posted by
billy
I kinda get it Russell.
This is what I have so far but its still incomplete. I have not been able to figure out how to get it setup correctly.
Very cool example indeed that seems very straight forward. But i am still puzzled on how to get this talking to fmcompute or fmcompute to this example.
How close am I to getting this puppy working?
Yes, this all looks exactly right.
So, the fmcomputes execute to process and create fields when the page is submitted.
Then, the next page is loaded and processed as a template. The template uses the fields that were submitted (and created by fcompute and derive_fields) previously.
-
Re: Need a little direction with fmcompute.
Quote:
Originally Posted by
russellr
Hi,
Yes, this all looks exactly right.
So, the fmcomputes execute to process and create fields when the page is submitted.
Then, the next page is loaded and processed as a template. The template uses the fields that were submitted (and created by fcompute and derive_fields) previously.
The problem lies in advance templates. When I load an advance template with the <if "$make_is_ford"> it will not show up in the form. I do not know how to get my advance templates to show?
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
I have not been able to hide your first fmcompute1 in my ini file. Any pointers on getting this to work? I have tried every way I can think of.
I don't think you should be using an INI file, but the process i straightforward.
Remember the same INI file is loaded for each page - so, the same computations will be executed on each page. That's not going to easily work for you.
You'd have to have a page identifier and then an IF statement with computations for each page.
All gets very messy.
Write down your threat model and determine exactly what needs to be hidden and why. Be minimalist.
E.g. does knowledge of your directory structure matter? If so, why?
E.g. does knowledge of the list of vehicles matter? If so, why?
etc. etc.
The easy answer is "I don't know - I just want to hide everything". In that case then you'd be better to take the road of writing everything in PHP, either using the Hook System or discard FormMail altogether.
But, that road leads to all sorts of security issues - writing secure PHP code is hard.
-
Re: Need a little direction with fmcompute.
Please give me one example on how to hide that fmcompute. Based on everything I have learned I will only need the one fmcompute on the front page. Your logic seems like it will do everything I need if I can get the templates working to.
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
I have not been able to hide your first fmcompute1 in my ini file. Any pointers on getting this to work? I have tried every way I can think of.
This fmcompute:
HTML Code:
<input type="hidden" name="fmcompute1" value="
import function FMUserError;
import string make;
import string year;
export string make_is_ford;
export string make_is_toyota;
export string year2009;
export string year2008;
export string year2007;
if (make == 'ford')
{
make_is_ford = '1';
}
" />
Goes into an INI file like this:
Code:
[special_fields]
fmcompute1 = "
import function FMUserError;
import string make;
import string year;
export string make_is_ford;
export string make_is_toyota;
export string year2009;
export string year2008;
export string year2007;
if (make == 'ford')
{
make_is_ford = '1';
}
"
To work with different pages (I mentioned this could get messy above), you can do this:
Code:
[special_fields]
fmcompute1 = "
import function FMUserError;
import int PageNumber;
if (PageNumber == 1)
{
/* logic for submission of first page */
import string make;
import string year;
export string make_is_ford;
export string make_is_toyota;
export string year2009;
export string year2008;
export string year2007;
if (make == 'ford')
{
make_is_ford = '1';
}
/* and so on.... */
}
elseif (PageNumber == 2)
{
/* logic for submission of second page */
import float Price;
if (Price < 1000)
{
FMUserError('Your car does not cost enough');
}
/* and so on.... */
}
elseif (PageNumber == 3)
{
/* logic for submission of third page */
}
"
Get the idea?
It's probably not as messy as I suggested.
-
Re: Need a little direction with fmcompute.
Oh you are the man! That looks like it will do it. Sweet! Russell what am I doing wrong with the advance templates. Your logic in the fmcomputes makes reference to the advance templates. Why wont they display? I have wrapped them in php tags, plain html and yet there is nothing but a blank page? Seems like something very basic is missing it's just weird.
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
Originally Posted by
billy
Oh you are the man! That looks like it will do it. Sweet! Russell what am I doing wrong with the advance templates. Your logic in the fmcomputes makes reference to the advance templates. Why wont they display? I have wrapped them in php tags, plain html and yet there is nothing but a blank page? Seems like something very basic is missing it's just weird.
I'll need to take a look.
Please tell me the url for your form so I can see the failure.
And, send me your formmail.php file, INI file and template file (email to supportstaff AT tectite DOT com).
-
Re: Need a little direction with fmcompute.
Okay give me a few minutes to set up the demo Russell because I have hacked the heck out of it trying to get it to work.
-
Re: Need a little direction with fmcompute.
I sent the files for the one html test site. I did not include the files for the data driven site. I put that together pretty fast. The point is I had everything in there from the start. The way I thought it should be. Then I whittled it all down to the basis and still could not figure out where I went wrong. So I am sure its not perfect but yet a small sample of the code your provided. Of course it does not have any of the new stuff you have posted today! I still need to catch up with that and chew on it a little.
I private messaged your the two urls.
Thanks for your time!
-
Re: Need a little direction with fmcompute.
Hi,
OK, one of them (the coloured one) seems to work fine.
BTW, you mentioned somewhere about a CMS.
It should all be able to work well together, but the usual problem is relative URLs.
So, if you have things like src="a-relative-url", then you can get into problems.
On the other hand, full URLs like "src="http://mysite.com/document.html" can often work best.
But, it all depends on the underlying systems and your directory structure.
There's no substitute for understanding what your systems (e.g. CMS and FormMail) require and planning your solution accordingly.
For example, if your CMS insists on using relative URLs, then you need to structure your directories and use appropriate URLs and paths inside FormMail.
The first step is understanding the problem(s).
-
Re: Need a little direction with fmcompute.
Quote:
OK, one of them (the coloured one) seems to work fine.
Good evening Russell,
Its just an iframe pulled into a custom html block. Nothing fancy at all. This is not the way I want to set up my site. You lose so much of the power and beauty of running data driven stuff.
Quote:
BTW, you mentioned somewhere about a CMS.
It should all be able to work well together, but the usual problem is relative URLs.
So, if you have things like src="a-relative-url", then you can get into problems.
On the other hand, full URLs like "src="http://mysite.com/document.html" can often work best.
For example, if your CMS insists on using relative URLs, then you need to structure your directories and use appropriate URLs and paths inside FormMail.
But, it all depends on the underlying systems and your directory structure.
Yep I understand and I should be able to get around some of this with mod_rewrite and a little more indepth cms that loves absolute urls. Thanks for pointing this out to me because it is a very important topic.
Quote:
There's no substitute for understanding what your systems (e.g. CMS and FormMail) require and planning your solution accordingly.
The first step is understanding the problem(s).
Amen
I was sitting here thinking just that Russell. I have been digging thru all the different systems I have used over the years. I have come up with a few winners in that regard. But I also come up short on the design aspect as they all wrap their systems pretty much the same way around custom apps.
Example:
Code:
<?
include_once 'includes/bla.php';
cms_page_header();
include_once 'includes/bla_bla.php';
// $status = menu_execute_active_handler();
$status1 = do_first_stuff();
include("myapp/index.php");
$status2 = do_other_stuff();
cms_page_footer();
?>
Directory called myapp which has an index.php file and other app files:
/myapp/index.php
/myapp/showbasic.php
/myapp/showdetails.php
etc.
btw bs code people...
Anyway Russell one of my major questions is How can I dynamically wrap your fm?
I have already had a run in with smarty. Seems like that is a show stopper to me!
As I am sure you already know how to wrap your code in stuff. I am going to take all this to emails if you don't mind?
-
Re: Need a little direction with fmcompute.
Hi,
Twenty minutes composing a reply to you and the idiot browser crashed and threw it all away! :mad:
-
Re: Need a little direction with fmcompute.
Yea I have all ready learned those issues the hard way. I am sitting here doing the same. Except in a .txt doc. I hate when that happens...
Anyway since you opened up that can of worms. Do you have vBulletin set to log everyone out after tens minutes? It might be less time than that... but it's going to drive me insane lol.
Email on the way man just a few more things to get sorted.
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
Anyway since you opened up that can of worms. Do you have vBulletin set to log everyone out after tens minutes?
It's set to keep you logged in unless you log out.
So, I guess you must have a cookie issue with your browser.
I'm always logged in forever.
-
Re: Need a little direction with fmcompute.
The following error occurred in FormMail :
fmcompute_exec
**********
Error=The following error messages were reported from the FMCompute module: Statement 6 on line 19, position 1, failed runtime expression evaluation: Invalid action 180. If one operand is a string, they both must be.
-
Re: Need a little direction with fmcompute.
I got this one... a few little ' is all it needed.
-
Re: Need a little direction with fmcompute.
Hi,
Yes, the parser and runtime system for the computations check for most errors.
Glad you found it.
-
Re: Need a little direction with fmcompute.
Hi Russell,
Can I change the fmcompute file name?
Say logic.php and then logic1 for the hidden field.
Can it be "cloned" to another name thru out the setup?
Can all the other file names.php be changed as well?
I would just like it to flow better and make more since in my setup.
I do like the names you have chosen to convey what they do.
But I want to clone them...
-
Re: Need a little direction with fmcompute.
Hi,
You can change the name of the fmcompute.php file in FormMail's configuration section:
PHP Code:
$FMCOMPUTE = "fmcompute.php";
As for changing the field names, you can only do that by changing the coding of FormMail. And then you'll have to re-do those changes when you upgrade.
It's not recommended.
I guess you want to do this for "security" reasons. However, I think I mentioned in a previous post that you should write down your threat model first.
You can think you're achieving "security" when all you're really doing is wasting your time.
So, start with a threat model (what are you worried about) and then develop solutions for that.
-
Re: Need a little direction with fmcompute.
I have been working on my plan. I am not really worried about threats. I just want to hide what I am using to make the forms work.
So if someone see the fields in my form then searches google for them. lol They wont end up here.
I know you want people to find your site. I just don't want anyone "meaning my competition" to understand how I am building my forms with one google search.
I certainly hope that, that does not offend you in anyway. My post is not meant to offend just to understand how I can achieve my goals for my project.
-
Re: Need a little direction with fmcompute.
Hi,
Quote:
Originally Posted by
billy
I just want to hide what I am using to make the forms work.
OK, why? (I think you've answered this below.)
Sounds like a security concern you have (also known as a "threat").
Quote:
So if someone see the fields in my form then searches google for
them. lol They wont end up here.
Search engines don't look in hidden fields. It makes no sense for them to do so.
In fact, they don't look inside the value of any fields in a form (non-hidden fields typically have no value anyway).
So, that won't happen.
The search you've mentioned is finding the contents of files people have linked to on their website.
They've done silly things like tell search engines to look inside a language pack.
Completely harmless, but silly.
If you actually look at the results, there are no "fmcompute" field values shown.
Quote:
I know you want people to find your site. I just don't want anyone "meaning my competition" to understand how I am building my forms with one google search.
Sounds like a security threat you're worried about.
So, be specific: write down a scenario that you want to prevent from happening.
Then, I can advise the best course of action to avoid that scenario.
You've just mentioned one, and I hope I've explained that it's not an issue.
Quote:
I certainly hope that, that does not offend you in anyway. My post is not meant to offend just to understand how I can achieve my goals for my project.
No offense taken in any way. :)