Print Page | Close Window

Tutorial: Packs Userspace - add more data fields

Printed From: openElement Website
Category:

openElement


Forum Name: User Tutorials
Forum Description: Browse or create a tutorial to get the most out of the openElement software.
Please do not post support questions in this section.
URL: http://forum.openelement.com/en/forum_posts.asp?TID=673
Printed Date: Sep 27 2021 at 5:59pm
Software Version: Web Wiz Forums 10.11 - http://www.webwizforums.com


Topic: Tutorial: Packs Userspace - add more data fields
Posted By: Dmit OE
Subject: Tutorial: Packs Userspace - add more data fields
Date 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.



Replies:
Posted By: Dmit OE
Date 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]);
    }
}

});



Posted By: Dmit OE
Date 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.


Posted By: Otoole
Date 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 https://www.aepweb.org/" rel="nofollow - 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!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 10.11 - http://www.webwizforums.com
Copyright ©2001-2012 Web Wiz Ltd. - http://www.webwiz.co.uk