Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Looking to add simple radio button to registration  (Read 5872 times)

0 Members and 1 Guest are viewing this topic.

RS-Designs

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Looking to add simple radio button to registration
« on: February 24, 2015, 03:24:33 pm »

Hello,

I am new to coppermine and hoping someone can help me out a little. I am trying to add a simple yes/no radio button to the registration page. I have read some other post on editing the registration page but they are adding alot more items then I need (Looks complicated)

I am hoping there is a "fairly" simple way to do this. I have some coding experience but not a ton.

I am running cpg1.5.34 with only 2 plugins (forums and download link)

Thank you in advance.
Logged

RS-Designs

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Looking to add simple radio button to registration
« Reply #1 on: February 25, 2015, 12:12:20 pm »

So I was doing so more digging through some of the files and came across the following:

in register.php there is a section for radio buttons.

Code: [Select]
case 'radio':

            // added the radio option for possible future use. The array definition would have to look like this:
            // array('radio', 'user_var', 'Text label', 'option 1','option 2'),
            // enabling this option requires changes in profile.php and usermgr.php as well

            if ($superCage->post->keyExists($element[1])) {
                $value = $superCage->post->getAlnum($element[1]);
            } else {
                $value = '';
            }

            if ($element[2]) {

                echo <<< EOT
    <tr>
        <td width="40%" class="{$row_style}"  height="25">
            {$element[2]}
        </td>
        <td width="60%" class="{$row_style}" valign="top">
            <input type="radio" name="{$element[1]}" id="{$element[1]}1" value="{$element[3]}" class="radio" />
            <label for="{$element[1]}1" class="clickable_option">{$element[3]}</label>
            <input type="radio" name="{$element[1]}" id="{$element[1]}2" value="{$element[4]}" class="radio" />
            <label for="{$element[1]}2" class="clickable_option">{$element[4]}</label>
        </td>
    </tr>

So I added the following around line 120 in register.php

Code: [Select]
$form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $icon_array['username'] . $lang_register_php['username'], 25),
        !empty($CONFIG['global_registration_pw']) ? array('password', 'global_registration_pw', $icon_array['password'] . $lang_register_php['global_registration_pw'], 25) : '',
        array('password', 'password', $icon_array['password'] . $lang_register_php['password']),
        array('password', 'password_verification', $icon_array['password'] . $lang_register_php['password_again']),
        array('input', 'email', $icon_array['email'] . $lang_register_php['email'], 255),
//Sharing
array('radio', 'sharing', 'Share', 'Yes','No'),
        array('label', $lang_register_php['optional_info'])

I also added 'sharing' into my english.php

Now the next part I am a little unsure of. In the radio code it says
Quote
enabling this option requires changes in profile.php and usermgr.php as well
But I don't really know what and where I should be adding to those files.

Any ideas or thought?

Thanks again in advance.
Logged

RS-Designs

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Looking to add simple radio button to registration
« Reply #2 on: March 02, 2015, 03:25:20 am »

Hello,

Ok I am starting to make a little bit of progress. I final got it to show up and be sent in email to admin when complete but the last thing I am trying to do is basic add a popup or small window that has information in it like the help question mark on the admin page.

I want it to appear after the text "Sharing" and before the radio button. Any Idea?

Code: [Select]
        $form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $icon_array['username'] . $lang_register_php['username'], 25),
        !empty($CONFIG['global_registration_pw']) ? array('password', 'global_registration_pw', $icon_array['password'] . $lang_register_php['global_registration_pw'], 25) : '',
        array('password', 'password', $icon_array['password'] . $lang_register_php['password']),
        array('password', 'password_verification', $icon_array['password'] . $lang_register_php['password_again']),
        array('input', 'email', $icon_array['email'] . $lang_register_php['email'], 255),
//Sharing
array('radio', 'user_var', $icon_array['coin'] . 'Sharing', 'Yes','No'), //I want it to appear after the text "Sharing" and before the radio button.
//S END
        array('label', $lang_register_php['optional_info'])
    );
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Looking to add simple radio button to registration
« Reply #3 on: March 02, 2015, 01:41:41 pm »

You mostly seem to be having a dialog in this thread with yourself ;)

Why don't you share the *total* picture of what it is you are trying to do. It seems like you are trying to ask the user, upon registration, whether they want to be sharing something. It is possible that what you are trying to achieve is already doable by others means without the method that you are trying to implement.
Logged

RS-Designs

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Looking to add simple radio button to registration
« Reply #4 on: March 02, 2015, 02:00:44 pm »

Yes Ron4mac, I am basically having a conversation with myself hoping that at some point someone will join in and help me.

Me end goal is it:

When someone is filling out the registration form they have the option (via radio button) to either have there work shared(download-able) or not.

I am not to worried about the setup after the registration. It is getting a radio button plus a pop-up which has the text in it describing what it means to have there work shared. (The same concept as the help icon on the admin side of things).

I hope this makes things a little clearer.

Thanks,
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Looking to add simple radio button to registration
« Reply #5 on: March 31, 2015, 10:20:08 am »

So all you currently need help with is to add the help box popup next to your radio button?
Logged

RS-Designs

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Looking to add simple radio button to registration
« Reply #6 on: March 31, 2015, 10:53:40 am »

So all you currently need help with is to add the help box popup next to your radio button?

Yes, That is the last thing I need for my radio button.

Thanks,
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Looking to add simple radio button to registration
« Reply #7 on: May 31, 2015, 09:12:41 pm »

Use something like this:
Code: [Select]
array('radio', 'user_var', $icon_array['coin'] . 'Sharing '.cpg_display_help('f=empty.htm&amp;h=lang_common[captcha_help_title]&amp;t=lang_common[captcha_help]', 470, 245), 'Yes','No'),
I used the example language data from the captcha help box. It's not possible to use custom text since cpg1.5.34, so you need to add the text you want to display to the language file(s) (at least english.php) and access the language string in the "h" and "t" parameter (have a look at the example to get an idea how it works, should be obvious):
Fixed XSS issue in SVN revision 8751. Since cpg1.5.34 it's not possible to pass custom text to help.php. Instead, you can just pass available language strings or parts of the documentation.
Logged
Pages: [1]   Go Up
 

Page created in 0.046 seconds with 19 queries.