Error 404 in 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
hernan
Posts: 26
Joined: 2020-06-22 18:56

Error 404 in custom pages

Post by hernan » 2020-07-07 11:43

Hi,

I'm creating a custom page, located in "hooks/my_custom_page.php"
Since my custom page is under hooks, the link to appGini Helper src: "hooks/AppGiniHelper.min.js" defined in header_extras.php is not working, showing a 404 error.
I know that's because it looks under hooks/hooks, since the page is already in hooks.

How could I modify the src in header_extras.php to handle pages located in hooks as well as all the other pages?

Thanks,

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

Re: Error 404 in custom pages

Post by jsetzer » 2020-07-08 04:49

(1) Starting from the specs for custom pages here, https://bigprof.com/appgini/help/advanc ... cess-pages, you have to define a constant named PREPEND_PATH:

Code: Select all

<?php
  // file: hooks/YOURCUSTOMPAGE.php
  define('PREPEND_PATH', '../');
  // ...
You can use that constant in hooks/header-extras.php, too:

Code: Select all

<!-- file: hooks/header-extras.php -->
<script src="<?=PREPEND_PATH?>hooks/AppGiniHelper.min.js"></script>
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: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Error 404 in custom pages

Post by jsetzer » 2020-07-08 04:52

(2) You can reference the fully qualified url, for example:

Code: Select all

<!-- file: hooks/header-extras.php -->
<script src="http://localhost/PATH/TO/YOUR/APP/hooks/AppGiniHelper.min.js"></script>
Please note
Alternative (1) is more dynamic and more flexible
Alternative (2) is shorter, but you will have to change the url when moving your app into a different location, for example after deployment to your remote server
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

hernan
Posts: 26
Joined: 2020-06-22 18:56

Re: Error 404 in custom pages

Post by hernan » 2020-07-09 09:37

Thank you so much.
I'll try the PREPEND_PATH, I don't know how I missed that....

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

SOLVED: Error 404 in custom pages

Post by jsetzer » 2020-07-27 19:29

Great!

By the way: when I started writing custom pages I saved them in hooks subdirectory. For a while now I am storing them in main directory instead of hooks directory and this works pretty well and I avoid trouble with paths. I know it's not the way the docs recommend. But I have made some good experiences.

Regards,
Jan
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