BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> User Tutorials
  New Posts New Posts RSS Feed - Tutorial: Packs Userspace - add more data fields
  FAQ FAQ  Forum Search   Register Register  Login Login

Tutorial: Packs Userspace - add more data fields

 Post Reply Post Reply
Author
Message
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Topic: Tutorial: Packs Userspace - add more data fields
    Posted: Mar 19 2016 at 1:28pm
Hi,

The Packs "Userspace01" (user management and page protection) does not allow to directly add more data to accounts. There's however a workaround for this.

Due to lack of time, I won't look into modifying the Edit Account page, just New Account and reading stored data. Upon request and with more free time I may look into Edit Account and add it later.

1) If you haven't installed the Packs yet: find the Packs tab/panel on the right, open Userspace01, and use Automatic installation option. As indicated, make sure to open the Admin page (one with the Pack #10) in local preview then, after uploading the website, online as well, to initilalize the database.

2) On the page New Account (one with Pack 30), hide the big "info" field  - uncheck Properties->Visible - and add Properties->Custom Class "comb-info" (without ""). This field will "collect" all extra data fields.

(Each time I have to tell without "" because there is always someone who puts "" otherwise..)

3) Add your additional elements-fields (ex. "Occupation", "Age" etc.), set their Properties->Attribute Name as needed - you will use these to access the data. On each of these elements, add Properties->Custom Classes "add-info" (yes, still without "").

4) Add a Code Block (Source) type Javascript position Header with the code:



$(function(){
    $('.add-info :input').change(function(){
        fillCombInfo();
    });
});

function fillCombInfo(){
    var $combInfo = $('.comb-info :input');
    $combInfo.val('');
   
    var combVals = {};
    $('.add-info :input').each(function(){
        combVals[$(this).attr('name')] = $(this).val(); // couples "Attribut name: valeur"
    });
    $combInfo.val(JSON.stringify(combVals));
}
   


This will, on each change of any "additional field", collect all data from all fields and store them into the invisible "info" field. Which, in turn, will be saved to the database by Packs on creating the account.

That's all you need to STORE the data into the database. Next post will be about getting this stored data.


Edited by Dmit OE - Mar 19 2016 at 1:52pm
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Mar 19 2016 at 1:45pm
Part 2 - showing stored data.

On a page that needs to show the data, use (if not already done) the Pack 70. It provides elements-fields for all built-in data, including "info" that stores all additional data.

Add elements-fields corresponding to all datas you want to get. For example, if you had the field named "age"on New Account page, add a field with the same Properties->Attribute Name "age" (yes yes still without "").

Delete all elements-fields added by the Pack that you don't need.

Make the "info" field invisible and put the Properties->Custom Classes "comb-info" as discussed in the previous post.

Now, all you need to do is add a Code Block Source type Javascript position Header with the code:



$(function(){

var info = $('.comb-info :input').val();
if (info) {
    JSON.parse(info);
    for (name in info) {
        var $el = $(':input[name="' + name + '"]');
        $el.val(info[name]);
    }
}

});



Edited by Dmit OE - Mar 19 2016 at 1:53pm
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (1) Thanks(1)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Mar 19 2016 at 1:47pm
P.S. Normally on Edit Account page you should just use the combination of the two parts described above, but I don't have time to test it atm.

You are welcome to give your feedback esp. if it does not work, I will fix and update the tutorial.
Back to Top
Otoole View Drop Down
Newbie
Newbie
Avatar

Joined: Oct 20 2017
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Otoole Quote  Post ReplyReply Direct Link To This Post Posted: Oct 29 2017 at 3:28pm
Originally posted by Dmit rOE Dmit rOE wrote:

P.S. Normally on Edit Account page you should just use the combination of the two parts described above, but I don't have time to test it atm.

You are welcome to give your feedback on bingo sites esp. if it does not work, I will fix and update the tutorial.


This is exactly what I've been looking for. Thanks for the efford and sharing!


Edited by Otoole - Jul 01 2019 at 7:01am
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.