Path variable to appgini installation

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Path variable to appgini installation

Post by SkayyHH » 2020-11-05 18:20

Hello,

maybe someone knows how I can use a path to the appgini directory as a variable? Is there a global variable to use?

i try something like this. I want to add a link to the menu. And would like to use a variable ("baseDir") for the path to the installation.

Code: Select all

<script>
 $j(function(){
     $j('nav .navbar-collapse').prepend(
            '<ul class="nav navbar-nav">' +
                 + '<a href=""baseDir"/hooks/calendar-Kalender.php" class="btn btn-default navbar-btn">Calendar</i></a>' +
            '</ul>'
     );
 });
</script>
Unfortunately I don't get any further with that.

I would be very happy about your help :-)

Thank you very much, Kai

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Path variable to appgini installation

Post by pbottcher » 2020-11-05 20:02

Hi,

try $_SERVER['CONTEXT_PREFIX']
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Re: Path variable to appgini installation

Post by SkayyHH » 2020-11-06 07:53

I thank you very much. I just have no idea how I can use this in the code.

This is not the way i think ;-)

Code: Select all

<script>
 $j(function(){
     $j('nav .navbar-collapse').prepend(
            '<ul class="nav navbar-nav">' +
                 + '<a href="$_SERVER['CONTEXT_PREFIX']/hooks/calendar-Kalender.php" class="btn btn-default navbar-btn">Calendar</i></a>' +
            '</ul>'
     );
 });
</script>
Thanks very much!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Path variable to appgini installation

Post by pbottcher » 2020-11-06 14:32

ok, try this:

Code: Select all

<script>
 $j(function(){
  var a = location.href.split('/');
  let del=a.splice(keys(a).find(key => a[key].indexOf('.php') >0));
  var basename=a.join('/');

       $j('nav .navbar-collapse').prepend(
            '<ul class="nav navbar-nav">' +
                 + '<a href='+basename+'/hooks/calendar-Kalender.php" class="btn btn-default navbar-btn">Calendar</i></a>' +
            '</ul>'
     );
 });
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Re: Path variable to appgini installation

Post by SkayyHH » 2020-11-06 15:17

Hello, thanks so much!

I still had one + too much in my code.

But it still doesn't work. It seems to be something with the definition of the variable. No entry appears in the menu.

Thanks again, Kai

Code: Select all

<script>
 $j(function(){
  var a = location.href.split('/');
  let del=a.splice(keys(a).find(key => a[key].indexOf('.php') >0));
  var basename=a.join('/');

       $j('nav .navbar-collapse').prepend(
            '<ul class="nav navbar-nav">' + '<a href=' + basename + '/hooks/calendar-Kalender.php" class="btn btn-default navbar-btn">Calendar</a>' + '</ul>'
     );
 });
</script>

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Path variable to appgini installation

Post by pbottcher » 2020-11-06 15:31

Where do you have the code?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Path variable to appgini installation

Post by pbottcher » 2020-11-06 15:37

ok, sorry, try

Code: Select all

<script>
 $j(function(){
  var a = location.href.split('/');
  let del=a.splice(Object.keys(a).find(key => a[key].indexOf('.php') >0));
  var basename=a.join('/');

       $j('nav .navbar-collapse').prepend(
            '<ul class="nav navbar-nav">' + '<a href=' + basename + '/hooks/calendar-Kalender.php" class="btn btn-default navbar-btn">Calendar</a>' + '</ul>'
     );
 });
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

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

Re: Path variable to appgini installation

Post by jsetzer » 2020-11-06 16:12

At least there is a double quote missing directly after href=, I think.
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 25.10 + all AppGini Helper tools

SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Re: Path variable to appgini installation

Post by SkayyHH » 2020-11-06 17:34

Thank you, Jan. That's it.

But now I still have the problem with the path.

The variable always takes the current url of the page as a basis. But I always need the installation url as basis.

Otherwise I have e.g. for a page within the hooks directory a link with double the "hooks" dir.
http: //localhost/appginimsy/hooks/hooks/calendar-Kalender.php

Thanks much, Kai

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Path variable to appgini installation

Post by pbottcher » 2020-11-06 18:46

In which file do you have the code?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Re: Path variable to appgini installation

Post by SkayyHH » 2020-11-06 23:44

I need the code in the header-extras.php. Therefore i need the path to the installation directory.
Kai

SkayyHH
Veteran Member
Posts: 481
Joined: 2015-04-27 21:18

Re: Path variable to appgini installation

Post by SkayyHH » 2020-11-10 19:45

For everyone who wants to know how to do it :-)

Code: Select all

<?php if(!defined('PREPEND_PATH')) define('PREPEND_PATH', '');?>

<a href="<?php echo PREPEND_PATH; ?>table_view.php"><b>.......</b></a>

Post Reply