Gossamer Forum
Home : Products : Links 2.0 : Customization :

Making "Receive Email" A User Option

Quote Reply
Making "Receive Email" A User Option
These instructions were posted in another thread but I am posting them here, again, in order that I will receive the email concerning the mod instead of someone else receiving the email. This mod allows the user to decide whether or not he/she wants to receive Email from the admin concerning the link being added or modified.

This is a mult-step process.

1. In links.def, change the ReceiveMail field to optional by changing the following:

Code:
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Rating => 0,
Votes => 0,
ReceiveMail => 'Yes'
);

to read:

Code:
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Rating => 0,
Votes => 0
);

2. In add.html and modify.html, add something like this to the add/modify form (I have it at the end of the form):

Code:
</td></tr><tr><td>
Receive Email:
</td><td>
If you do not want to receive email about changes<br>that may affect this resource, select "No"<br>
<input type="radio" name="ReceiveMail" value="Yes" checked> Yes
<input type="radio" name="ReceiveMail" value="No"> No
</td></tr></table>

3. In add_error.html and modify_error.html, include the following for the form (I added it at the end):

Code:
</td><td>
If you do not want to receive email about changes<br>that may affect this resource, select "No"<br>
<%radio_button%><br>
</td></tr></table>

For non-templates, the changes in step 2 should be made to sub site_html_add_form and sub site_html_modify_form in site_html.pl while step 3 should be made to sub site_html_add_failure and sub site_html_modify_failure in site_html.pl (except that you use $radio_button, not <%radio_button%> ).

4. In sub site_html_add_failure and sub site_html_modify_failure, site_html_templates.pl or site_html.pl, add the following after my ($errormsg) = shift;:

Code:
my $radio_button;

if ($in{'ReceiveMail'} eq "Yes") {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes" checked> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No"> <b>No</b>|;
}
else {
$radio_button = qq|<input type="radio" name="ReceiveMail" value="Yes"> <b>Yes</b>
<input type="radio" name="ReceiveMail" value="No" checked> <b>No</b>|;
}

Please post any questions or problem reports concerning this mod in this thread or by sending me email. Thanks.

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/










Quote Reply
Re: Making "Receive Email" A User Option In reply to
Bobsie,

I see the sentence

Quote:
If you do not want to receive email about changes that may affect this resource, select "No"

but no Yes/No radio buttons after that. I just see the "Add Resource" button. I double-checked the code in step 4. Do you know what might be the problem?

Thanks.
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Are you passing $radio_button to the template using the radio_button => $radio_button, in the template loading instructions?
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Yep.
Quote Reply
Re: Making "Receive Email" A User Option In reply to
And this is in add_error.html?

Quote:
<b>If you do not want to receive email about changes to<br>Bob's Good Stuff Lists that may affect this resource,<br>select "No"</b>
<%radio_button%><br>

If it is, it should work. If it is but is not working, something is wrong someplace else. The fact that you are having other problems with other <%links_tags%> may indicate that the script is not working right. Perhaps something is wrong in Template.pm. Are you using the Template.pm from the default Links distribution, or are you using the modified one from the Resource Center?
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Yes, I added your code to add_error.html. I am still using the original Template.pm.
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Send me a copy of the files (listed in my original post) that you modified. Something has to be wrong in them. Also, advise as to what other mods you have installed that may impact on those files.

[This message has been edited by Bobsie (edited June 17, 1999).]
Quote Reply
Re: Making "Receive Email" A User Option In reply to
I've sent you an email with the problem files attached. Hope you can find the problem.

Thanks.
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Previously, I asked:

Code:
print &load_template ('add_error.html', {
error => $errormsg,
%in,
%globals
});

I don't see it.

[This message has been edited by Bobsie (edited June 17, 1999).]
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Oops. I thought "radio_button => $radio_button" goes in the globals section. Sorry for the misunderstanding.
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Would you mind telling me how I can add a field to the add_confirm and add_success pages to show the user's choice regarding receiving email? add_confirm.html is from Phoenix's mod at http://www.gossamer-threads.com/...es/Detailed/173.html .

Thanks.
Quote Reply
Re: Making "Receive Email" A User Option In reply to
T-Dog,

In this mod, all tags are built the same, no matter what sort of field they are.

So for add_confirm, you'd put in
Code:
Receive email updates? <%ReceiveMail%> <input type="hidden" name="ReceiveMail" value="<%ReceiveMail%>">

And in add_success you'd put the same thing minus the hidden form field. (Assuming I typed that correctly Wink )

Phoenix
Quote Reply
Re: Making "Receive Email" A User Option In reply to
OK. I get it. I think I'm starting to understand how these tags and fields work Smile
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Bobsie,

I've tried implementing your mod as described. I get the button on my form, but a NO selection doesn't show up when validating the link in admin.cgi (it always stays as YES). Do you know why this might be?

thanks, RogerW

Quote Reply
Re: Making "Receive Email" A User Option In reply to
Did you delete ReceiveMail => 'Yes' from your %add_system_fields hash in the links.def file?

Regards,

Eliot Lee
Quote Reply
Re: Making "Receive Email" A User Option In reply to
Gee, I swear I had done - but obviously didn't save the file or uploaded the original version again or something.
Thanks a lot - I feel kinda stupid now.
Roger.

Quote Reply
Re: Making "Receive Email" A User Option In reply to
You're welcome.

Regards,

Eliot Lee