Buy Now
Sign in

Unanswered Or Irrelevant Question Management

indieben , March 14 at 20:17
I
indieben 120
March 14 at 20:17 #384851
A few questions please:
1) Is it possible to avoid having unanswered questions (whether they were disabled and hidden through the form conditions or not) displaying within Custom Email Setups? If so, how do you go about that please?
2) Is it possible to create an alternative phrase for unanswered questions (for example: "The Client Does not Require This Service" and have a slightly different version for the Client: "You Have Stated That You Do Not Require This Service"
3) In a checkbox situation, is it possible to hav/calle the value displayed to the user on the website sent in the Email instead of the internal value. y=yes etc.
Thanks ever so much.
healyhatman 6.1
March 14 at 21:23 #384854
1) You can craft the email yourself manually instead of relying on auto added fields. You can do this in a custom code block set to "return as var" where you use HTML and PHP to echo / display whatever you want, then just use {var:custom_code_block_name} in your email body.
2) Again you can put whatever you want.
3) No. Unless you manually do it as described above.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 14 at 21:25 #384855
Thanks for this, are there any up to date Chronoforms instructions out there? I know the question has been asked once or twice before but as Chronoforms is constantly evolving, things may have come a darn site easier than it looked before...
Thanks.
healyhatman 6.1
March 14 at 21:34 #384859
Nope he's been too busy fixing bugs and adding new features to be able to add new stuff to a manual. What are you after exactly?
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 14 at 22:26 #384860
Where to start with achieving the above essentially, i'd hoped that there were some guides (not necessarily the official manual) that are trusted amongst regulars... I have no idea where to start with the above!
Thanks.
healyhatman 6.1
March 14 at 22:34 #384861
1
In a Custom Code block set to return var
<?php
echo "This field will show Not Answered if it's not there: " . ($this->data("fieldname") ?: "Not answered");
?>
<br>
More Text Goes here!
<?php
if(!empty($this->data("myotherfieldname"))) {
echo "This field exists so I will show it otherwise I wouldn't show anything: " . $this->data("myotherfieldname");
}
?>
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 14 at 23:12 #384862
Bless you healyhatman, I shall play with this. Thanks a hell of a lot. May come back to you - please have patience with me if I fudge it up!
I
indieben 120
March 15 at 01:49 #384864
Hi Healyhatman,
A) So - How do the two work different in practice (i.e. in straight English please)?:
1)
echo "This field will show Not Answered if it's not there: ...
2)
if(!empty($this->data("myotherfieldname"))) { ...
3. I notice in the case of example 2 - it goes on:
 echo "This field exists so I will show it otherwise I wouldn't show anything: " . $this->data("myotherfieldname");
So, in the second example, it takes two fields, what is the difference please? I presume the field names are the green ones instead of the black ones?
C) I presume the custom code block would go at the top of the form or somewhere within the design view of the form?
D) The "block name", I'm not familiar with the blocks bit, how do I get that please?
C) Do I call all the fields in the same way as normal (within the Email Section) but the PHP overrides it - essentially an expected behaviour question?
Sorry if I appear dumb, i'm sure this will help a fair few people
Thanks!
healyhatman 6.1
March 15 at 02:38 #384865
A) 1) Shows a label and the either the value of the field OR if it wasn't answered a message saying "Not Answered"
2) If the question wasn't answered, doesn't show anything. 2 is the part that checks if it was Not Empty, 3 is the part that displays the message.
C) It goes before your email action.
D) "Custom code block name" is the name of your custom code block.
C (again for some reason, I assume you mean E)) No like I said you put {var:custom_code_block_name} in the email body. If your code block was named like the one in the picture it would be {var:custom_code3}
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 15 at 17:39 #384880
Thanks for this.
So in version 1 at https://pastebin.com/0zBrKyRh I realised that the:
This field will show Not Answered if it's not there
will print out - fine - no surprise that that happens.
So I developed version 2 to get rid of that:
But both forms display to the user on the screen - they shouldn't - I'll use a standard display message for that and neither actually carry out the substitution in the Email generated if a field value is left blank.
Sorry to be rather slow here I have asked around and drawn a blank.
Thanks,
indieben.
healyhatman 6.1
March 15 at 19:55 #384884
Did you tick the return as var button?
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 16 at 17:50 #384914
I hadn't but I tried it with that and it still displayed on the screen and does not output the substituted message for the field in the Email when the particular question isn't completed - it does appear to omit some fields if they are not completed though but, not, for example, "Is the Trainee Based in the Uk" on this form https://www.samspencerit.co.uk/index.php/quotation-request
Thanks
healyhatman 6.1
March 16 at 22:46 #384921
If you ticked the box there's no reason the code you've put in should be displayed on the screen unless you're telling it to.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 17 at 15:41 #384938
Sure, i must have got something wrong unless Gantry Is doing something odd!! I’ll run off a copy of Joomla without Gantry and see if that changes anything - i’ll pastebin the current code I’m using too ( an adaptation of yours) if you’d be kind enough to double check that.
Thanks ever so much!
I
indieben 120
March 21 at 06:48 #385125
OK, ruled out Gantry and moved the form over to a clean Joomla install. No difference. The current code is available at https://pastebin.com/WbVyjjqR - the PHP channel on IRC say that my code is not valid. I can't see how it is different from yours since it was outputting the message at the start: "This field will show Not Answered if it's not there:
"This field will show Not Answered if it's not there:
Please would you point out if I have got the code wrong.
Thanks.
healyhatman 6.1
March 21 at 07:49 #385126
You're not actually DOING anything with the data buddy.
<?php
($this->data("direct_request_check") ?: "Not answered");
That doesn't DO anything. You told it to get the value but haven't told it to assign it, or print it, or anything. You need to echo it out. Plus you have to put the label first.
You should be doing something like the following. I assume the direct_request_check is a checkbox that has a value of 1 and a ghost value of 0.
Direct Request Check: <?php echo $this->data("direct_request_check") ? "Checked" : "Not checked"; ?>
<br>
Enquirer First Name: <?php echo $this->data("enquirer_first_name") ?: "Not answered"; ?>
<br>
etcetcetc
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 21 at 07:52 #385128
Aha, bit different than i'd originally thought depending on the field type! It's actually a radio button so how would that work compared to the checked/not checked above please?
Thanks - hope you have had a good week so far!
healyhatman 6.1
March 21 at 08:03 #385130
It's just an example. If it's a radio then it depends on the value being sent by the field. You might just have to consider having someone like me do it for you for a fee. Here's another example, assuming a radio group with 3 possible values
Favourite Fruit: 
<?php switch($this->data("fav_fruit")) {
case 1: echo "apple"; break;
case 2: echo "banana"; break;
case 3: echo "tomato"; break;
}
?>
<br>
Or if you want to use a switch action (NOT switch event)
data source: {data:fav_fruit}
name: fav_fruit_switch
Return as var: checked
Content:
1:apple
2:banana
3:tomato
And then in your custom code email body building block
Favourite Fruit: {var:fav_fruit_switch}
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums
I
indieben 120
March 21 at 08:08 #385131
so the first example is a switch event, the second is a switch action? Would these go ahead of the Email action, by this point I will have the Email custom code and the code above, is there any specific order required for the two blocks ahead of Email? Also could this not be done a lot more simply by using isset and a check on that?
Thanks.
healyhatman 6.1
March 21 at 08:58 #385136
No, the first example (of favourite fruit) is a PHP switch statement. I haven't recommended a switch event for anything you're trying to do.
And if they were AFTER the email action, then the email will have already been sent when it's time to run the code. So it goes before it. And no, isset is for a VARIABLE, whereas $this->data is a function. isset($this->data("fieldname")) will (most likely) always be true. If you want, you can use if empty. But it won't be easier, because the first example (for Direct Request Check) becomes like this
Direct Request Check: 
<?php if(empty($this->data("direct_request_check"))) {
echo "Not checked";
}
else {
echo "Checked";
}
?><br>
Enquirer First Name:
<?php if(empty($this->data("enquirer_first_name"))) {
echo "Not answered";
}
else {
echo $this->data("enquirer_first_name");
}
?><br>

And I think that surely we can both agree that's not in any way "easier" than using the ternary operators I used in the first (Direct Request Check) example.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman

You can now copy+paste code from forums