Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: Contact form - add language function for *=required?  (Read 3345 times)

Jochum Meester

  • Sr. Member
  • ****
  • Karma: 1
  • Posts: 309
    • JochumMeester.com
Contact form - add language function for *=required?
« on: April 23, 2007, 09:31:12 PM »

I feel silly for making a topic for such a small thing, but since the contact form has an asterisk (sp?) in it, should we add a language function? I've added the blue part to my snews.php:

Quote
// LANGUAGE VARIABLES

   #contact
   $l['required'] = '* = required field';
   $l['email'] = 'Email';
   $l['message'] = 'Message';
Quote
// CONTACT FORM
function contact() {
    if (!isset($_POST['contactform'])) {
        echo '

'.l('contact').'

';
        echo '

'.l('required').'

';

        html_input('form', '', 'post', '', '', '', '', '', '', '', '', '', 'post', db('website'), '');
Logged

brauck

  • Hero Member
  • *****
  • Karma: 18
  • Posts: 556
    • http://www.hbw-webdesign.nl/
Contact form - add language function for *=required?
« Reply #1 on: April 25, 2007, 04:54:31 PM »

make sense   ;)
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
Contact form - add language function for *=required?
« Reply #2 on: April 25, 2007, 06:18:41 PM »

Here's a little tweak if you're interested:

Prerequisites:
Language variable
Quote
$l['required'] = 'required field';
CSS rule
Quote
.required {your-style-rule-here}
snews.php editing procedure:
Quote
function html_input(.....) {
# remove or comment this line
//$lbl = !empty($label) ? '' : '';

# and replace it with this piece of code

$required = ' '.l('required').'';
$lbl = !empty($label) ? '' : '';
//...
}
Usage:
This snippet will search through your label and replace space+asterisk with your 'required field' language variable. If space+asterisk doesn't exists, label is displayed as usual.

Example:
Quote
//PHP source
// Option 1.
//place asterisk at the end of your label for required field
html_input('text', 'url', 'url', '', l('url').' *', 'text', '', '', '', '', '', '', '', '', '');

//Option 2.
//place asterisk at the end of your label language variable
$l[url]= 'Website URL *';
html_input('text', 'url', 'url', '', l('url'), 'text', '', '', '', '', '', '', '', '', '');
Quote
//Resulting HTML source


...

Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version