Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Session hash variables

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
mariri
Posts: 45
Joined: Mon Sep 02, 2019 11:54 am

Session hash variables

Unread post by mariri »

Hi guys !

I want to add a new session hash variable like the hash cookie "USER_ID" which is always available.
I know how to declare the variable (file : nuformclass.js, function : addBreadcrumb() in the class "nuFormObject") but I don't know where can I set the property of this variable ? In which file ?

Do u have any idea ????

Thanks in advance !
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Session hash variables

Unread post by kev1n »

Hi,

Does this variable contain a static value or is it retrieved from a DB table?
mariri
Posts: 45
Joined: Mon Sep 02, 2019 11:54 am

Re: Session hash variables

Unread post by mariri »

A static value like the login and the password entered when you log in !

Thanks !
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Session hash variables

Unread post by kev1n »

You can use nuSetProperty() to set a hash cookie - e.g. under setup -> header
https://wiki.nubuilder.cloud/ ... etProperty
mariri
Posts: 45
Joined: Mon Sep 02, 2019 11:54 am

Re: Session hash variables

Unread post by mariri »

Thanks for ur anwser. I tried ur solution but it doesn't work
I don't know if I'm doing things correctly :(

To be more precise, I added a select (named 'nuservice') in the file nuconfig.php :

<div id='outer' style='width:100%'>
<div id='login' class='nuLogin'>
<table>
<tr>
<td align='center' style='text-align:center;height:50px' colspan='2'>
<div id='nulogo' style='margin:50px 0px 20px 65px;background-size:100% 100%;background-image:url(\"graphics/logo.png\");width:200px;height:80px;'></div>
</td>
</tr>
<tr>
<td style='text-align:right;margin:0px 5px 0px 20px;'><span style='padding:0px 5px 0px 40px;'>Login</span></td>
<td style='text-align:left'><input id='nuusername'/></td>
</tr>
<tr>
<td style='text-align:right;margin:0px 5px 0px 20px;'><span style='padding:0px 5px 0px 40px;'>Mot de passe</span></td>
<td style='text-align:left'><input id='nupassword' type='password' onkeypress='nuSubmit(event)'/></td>
</tr>

<tr>
<td style='text-align:right;margin:0px 5px 0px 20px;'><span style='padding:0px 5px 0px 40px;'>Service</span></td>
<td style='text-align:left'>
<select id='nuservice' style='width:172px;'>
<option value='1'>OCCITANIE 09</option>
<option value='2'>OCCITANIE 31</option>
<option value='3'>OCCITANIE 34</option>
<option value='4'>OCCITANIE 46</option>
<option value='5'>OCCITANIE 82</option>
<option value='6'>PRIR 03</option>
<option value='7'>PRIR 63</option>
<option value='8'>PRIR 45</option>
</select>
</td>

</tr>
<tr>
<td style='text-align:center' colspan='2'>
<input id='submit' type='button' class='nuButton' style='margin:20px 0px 0px 50px;width:90px;height:30px;' onclick='nuLoginRequest()' value='Log in'/>
</td>
</tr>
</table>
</div>
</div>


I added this code in the file nuformclass.js (a hash variable named 'service' appears in the list of the hash variables) :

addBreadcrumb(){

var b = {};
b.form_id = '';
b.redirect_form_id = '';
b.record_id = '';
b.title = '';
b.call_type = '';
b.column_widths = 0;
b.filter = '';
b.forms = [];
b.iframe = 0;
b.lookup_id = '';
b.object_id = '1';
b.page_number = 0;
b.password = '';
b.rows = -1;
b.row_height = 25;
b.search = '';
b.session_id = '';
b.nosearch_columns = [];
b.sort = '-1';
b.sort_direction = 'desc';
b.subforms = 0;
b.tab_start = [];
b.username = '';
b.user_id = '';

b.service = '';

this.breadcrumbs.push(b);

return this.getCurrent();
}

I tried ur solution by adding this code under setup -> header but it doesn't work :

function nuHeaderTest() {
console.log('Functions placed here before a closing script tag are available anywhere in nuBuilder Forte');
}

nuSetProperty('service', 'nuservice');

</script>
<style>

</style>
<script>



Like the hash cookie "USER_ID", I'd like to use the option value selected for 'service' at any time on Nubuilder.
Sorry I'm new on Nubuilder and I don't know too much about :(
mariri
Posts: 45
Joined: Mon Sep 02, 2019 11:54 am

Re: Session hash variables

Unread post by mariri »

Ok I got it !!!

I add a code in the function nuGetUserAccess() in the nucommon.php file and it works perfectly

Thanks for ur help kev1n !!! :P
Post Reply