Jump to content

[SOLVED] Making some radio buttons checked by default in authentication page using parameters


Recommended Posts

I've changed the authentication page so instead of the useless Mr and Ms I've added some account types. So now I have 3 account types where users could choose what type of account they want.

Now I want to make something a little more advanced: in the page where I describe the 3 account types, I want to put the login url for everyone, so that when users choose, for example, account type 1, the corresponding radio button to be checked by default.

Something like www.mydomain.com/authentication.php?id_gender=1 (possibly be another variable, e.g. acc_type - for users not to see that I'm using something like gender in the account type - but do not have to change the name id_gender of the radiobutton).

Unfortunately, the above link doesn't work how I thought; I'm not a programmer so I don't know where I'm wrong.

Can anyone help me?

Link to comment
Share on other sites

Hi,

 

Could you please :

- explain how you did solve your problem.

Thanks a lot.

 

Well, this is harder than the work itself :))

 

I've worked with presta 1.4.4

 

First of all, I've changed the label for Mr and Ms (it can be done in admin -> tools -> translations or directly in themes/yourtheme/authentication.tpl) with something like account1 and account2

 

Now, I have a page where I explain what these accounts are, and near each of them I've put a link like:

 

www.mydomain.com/authentication?acc_type=account1

 

In themes/yourtheme/authentication.tpl I've added on line 47 I've added:

 

{$account = (Tools::getValue('acc_type'))}

 

then find

 

<input type="radio" name="id_gender" id="id_gender1" value="1" {if isset($smarty.post.id_gender) && $smarty.post.id_gender == 1}checked="checked"{/if} />

 

and replace with

 

<input type="radio" name="id_gender" id="id_gender1" value="1" {if $account == 'account1'}checked="checked"{/if} />

 

In the same way you can put some default text in the Information textarea, for example if you have for account1 two packs: pack1 and pack2:

 

Add at line 48 (after you added all the codes above)

 

{$packs = (Tools::getValue('pack'))}

 

then find

 

<textarea name="other" id="other" cols="26" rows="3">{if isset($smarty.post.other)}{$smarty.post.other}{/if}</textarea>

 

and replace with

 

<textarea name="other" id="other" cols="26" rows="3">{if isset($packs) && $packs == 'pack1'}I want to buy the first Pack (or whatever you want){/if}{if isset($packs) && $packs == 'pack2'}I want to buy the second pack{/if}{if isset($smarty.post.other)}{$smarty.post.other}{/if}</textarea>

 

This way, you will have in the Information textarea some text you want by default and the users are still able to enter their texts.

 

I wanted to make the default text not to be changed, but I didn't know how.

 

Oh, I've forgot: If you want both the radio button checked and some default text in the Information, the link you can call this is:

 

www.mydomain.com/authentication?acc_type=account1&packs=pack1

Link to comment
Share on other sites

×
×
  • Create New...