script not working with custom pages

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
graham
Veteran Member
Posts: 86
Joined: 2020-09-29 12:30

script not working with custom pages

Post by graham » 2020-10-30 14:32

Hi, I used the: <script>
new AppGiniCommon().setTitle("<b>PROJECT_</b>DataTool");
</script>
<script>
new AppGiniCommon().setIcon("plus");
</script>
<script>
var common = new AppGiniCommon();
common.autoRedirect();
</script>
within the JS purchased library to personalise the home button name and link. It works fine (added to hooks/header-extras.php) in normal TV/DV pages but doesn't appear* on custom pages (as added in recommended way - https://bigprof.com/appgini/help/advanc ... cess-pages). How can I get the script to work in the custom pages as well as the main pages? Thanks.
*I just get the standard house glyphy thing and the original title.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: script not working with custom pages

Post by jsetzer » 2020-10-30 16:24

tl;dr

Code: Select all

<!-- file: hooks/header-extras.php -->
<script src="<?=PREPEND_PATH?>hooks/AppGiniHelper.min.js"></script>
--
Hi,

there is a chapter named "Tips / Custom pages" on the "how to integrate" page:
https://appgini.bizzworxx.de/products/j ... tegration/

According to the docs you have mentioned (https://bigprof.com/appgini/help/advanc ... cess-pages) you will have set the PREPEND_PATH constant in the beginning of your custom page:

Code: Select all

// ...
define('PREPEND_PATH', '../');
// ...
That constant can be used in hooks/header-extras.php for resolving the correct path to the hooks directory.

Just replace...

Code: Select all

<script src="hooks/AppGiniHelper.min.js"></script>
...by...

Code: Select all

<script src="<?=PREPEND_PATH?>hooks/AppGiniHelper.min.js"></script>
You will find a similar question and answers in this older thread here:
viewtopic.php?t=3752
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: script not working with custom pages

Post by jsetzer » 2020-10-30 16:38

By the way: I recommend initializing objects like AppGiniCommon only once.

So instead of...

Code: Select all

<script>
new AppGiniCommon().setTitle("<b>PROJECT_</b>DataTool");
</script>
<script>
new AppGiniCommon().setIcon("plus");
</script>
<script>
var common = new AppGiniCommon();
common.autoRedirect();
</script>
... (which is triple initialization of an object of class AppGiniCommon) ...
... I recommend ...

Code: Select all

<script>
new AppGiniCommon()
  .setTitle("<b>PROJECT_</b>DataTool")
  .setIcon("plus")
  .autoRedirect();
</script>
... (which is a single initialization) ...
... or ...

Code: Select all

<script>
var common = new AppGiniCommon();
common.setTitle("<b>PROJECT_</b>DataTool");
common.setIcon("plus");
common.autoRedirect();
</script>
... for avoiding side effects and for better readability.

Recommendations @all

According to the updated docs here https://appgini.bizzworxx.de/products/j ... mentation/ there is a recommendation especially for DV but also for TV. In DV there were a few problems, users reported, when initializing AppGiniDetailView multiple times, for example in header-extras AND in TABLENAME-dv.js.

Recommendation for DV

Code: Select all

var dv = AppGiniHelper.DV;
// your code here
Recommendation for TV

Code: Select all

jQuery(document).ready(function() {
  var tv = AppGiniHelper.TV;
  // your code here
});
Your code should still work, but in case you are facing problems with multiple initializations, please get used to using the new helper functions which are available since version 2020/10
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply