Hash Cookies: Difference between revisions

From nuBuilderForte
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
...What?
...What?


*A cookie helps hold variables between Javascript and PHP.  
 
*A cookie helps hold values between JavaScript and PHP.  
*A nuBuilder cookie does a similar thing and has hashes around it eg. '''#USER_ID#'''.
*A nuBuilder cookie does a similar thing and has hashes around it eg. '''#USER_ID#'''.


Line 8: Line 9:




In each of these situations, nuBuilder does a search and replace.
In each of these situations, nuBuilder does a search and replace with all currently available Hash Cookies and any you use in your code before it is run.


With all currently available Hash Cookies and any you use, before it is run.
These Hash Cookies are always available.
 
There are 4 Hash Cookies always available.
#USER_ID
#USER_ID
#USER_GROUP_ID
#USER_GROUP_ID (Access Level Id)
#USER_CODE
#USER_NAME
#USER_TEAM
#USER_DEPARTMENT
#USER_POSITION
#LANGUAGE
#ACCESS_LEVEL_CODE
#HOME_ID
#HOME_ID
#GLOBAL_ACCESS
#GLOBAL_ACCESS
#USER_ADDITIONAL1
#USER_ADDITIONAL2




Line 26: Line 34:


Example of using Hash Cookies in PHP.
Example of using Hash Cookies in PHP.
<source lang="php">


$s = "CREATE TABLE #TABLE_ID# SELECT * FROM invoice";
  $s = "CREATE TABLE #TABLE_ID# SELECT * FROM invoice";
  nuRunQuery($s);


nuRunQuery($s);
'''$nudata''' contains the form field values in Before Save (BS) PHP script that will be inserted / updated by '''nuUpdateDatabase()''' defined in <tt>nudata.php</tt>.


</source>
Form fields can be referenced in such PHP scripts as:
$ssn ="#cus_ssn#";


'''Ref:''' [https://forums.nubuilder.cloud/viewtopic.php?f=20&t=10823#p23095 Forum Post]
[https://forums.nubuilder.cloud/viewtopic.php?f=20&t=10823#p23110 Changing form field values in BS was experimental] and now stands [https://github.com/nuBuilder/nuBuilder-4.5/commit/ea45557e4c72a49451d2d5f0b2dacb2fceeca538 committed] as of 2021-02-15.


==HTML==
==HTML==
Line 41: Line 53:


Example of using Hash Cookies in HTML.
Example of using Hash Cookies in HTML.
<source lang="html">


<iframe  
  <iframe  
  width="560"  
    width="560"  
  height="315"  
    height="315"  
  src="#cus_youtube#"  
    src="#cus_youtube#"  
  frameborder="0" allowfullscreen>
    frameborder="0" allowfullscreen>
</iframe>
  </iframe>
 
</source>


==Custom SQL==
==Custom SQL==
All Custom SQL used in nuBuilder Forte.
All Custom SQL used in nuBuilder Forte.
<source lang="sql">


CREATE TABLE #TABLE_ID# SELECT * FROM customer;


</source>
  CREATE TABLE #TABLE_ID# SELECT * FROM customer;
 
 
or
 
 
  SELECT * FROM customer WHERE cus_group = '#sales_group#';


==SQL Builder==
==SQL Builder==
Any '''Clause''' in the '''Clauses''' Subform in the [[SQL Builder]].
Any '''Clause''' in the '''Clauses''' Subform in the [[SQL Builder]].


<source lang="html">
    = '#RECORD_ID#'
= '#RECORD_ID#'
</source>


==Report Labels==
==Report Labels==
Line 72: Line 83:


An example of using Hash Cookies in a Report Label.
An example of using Hash Cookies in a Report Label.
<source lang="html">


Sales Between #from_date# And #to_date#
  Sales Between '#from_date#' And '#to_date#'
 
 
The following are specific hash variables available only for Report Labels are...


</source>
*page
*pages
*description
*code
*year
*month
*day
*hour
*minute
*second

Latest revision as of 12:24, 22 February 2023

...What?


  • A cookie helps hold values between JavaScript and PHP.
  • A nuBuilder cookie does a similar thing and has hashes around it eg. #USER_ID#.


There are a number of places Hash Cookies can be used...


In each of these situations, nuBuilder does a search and replace with all currently available Hash Cookies and any you use in your code before it is run.

These Hash Cookies are always available.

  1. USER_ID
  2. USER_GROUP_ID (Access Level Id)
  3. USER_CODE
  4. USER_NAME
  5. USER_TEAM
  6. USER_DEPARTMENT
  7. USER_POSITION
  8. LANGUAGE
  9. ACCESS_LEVEL_CODE
  10. HOME_ID
  11. GLOBAL_ACCESS
  12. USER_ADDITIONAL1
  13. USER_ADDITIONAL2


To find what other Hash Cookies are available for use, you can run nuHash() inside your code.


PHP

Hash Cookies allow you to customise your PHP code.

Example of using Hash Cookies in PHP.

  $s = "CREATE TABLE #TABLE_ID# SELECT * FROM invoice";
  nuRunQuery($s);

$nudata contains the form field values in Before Save (BS) PHP script that will be inserted / updated by nuUpdateDatabase() defined in nudata.php.

Form fields can be referenced in such PHP scripts as:

$ssn ="#cus_ssn#";

Ref: Forum Post

Changing form field values in BS was experimental and now stands committed as of 2021-02-15.

HTML

Hash Cookies allow you to customise your HTML Objects.

The Hash Cookies available to HTML Objects are the same as those available on Before Edit.

Example of using Hash Cookies in HTML.

  <iframe 
    width="560" 
    height="315" 
    src="#cus_youtube#" 
    frameborder="0" allowfullscreen>
  </iframe>

Custom SQL

All Custom SQL used in nuBuilder Forte.


  CREATE TABLE #TABLE_ID# SELECT * FROM customer;


or


  SELECT * FROM customer WHERE cus_group = '#sales_group#';

SQL Builder

Any Clause in the Clauses Subform in the SQL Builder.

   = '#RECORD_ID#'

Report Labels

Using Hash Cookies allows you to have changing titles on Report Labels.

An example of using Hash Cookies in a Report Label.

  Sales Between '#from_date#' And '#to_date#'


The following are specific hash variables available only for Report Labels are...

  • page
  • pages
  • description
  • code
  • year
  • month
  • day
  • hour
  • minute
  • second