Page 1 of 1
Path variable to appgini installation
Posted: 2020-11-05 18:20
by SkayyHH
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
Re: Path variable to appgini installation
Posted: 2020-11-05 20:02
by pbottcher
Hi,
try $_SERVER['CONTEXT_PREFIX']
Re: Path variable to appgini installation
Posted: 2020-11-06 07:53
by SkayyHH
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!
Re: Path variable to appgini installation
Posted: 2020-11-06 14:32
by pbottcher
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>
Re: Path variable to appgini installation
Posted: 2020-11-06 15:17
by SkayyHH
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>
Re: Path variable to appgini installation
Posted: 2020-11-06 15:31
by pbottcher
Where do you have the code?
Re: Path variable to appgini installation
Posted: 2020-11-06 15:37
by pbottcher
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>
Re: Path variable to appgini installation
Posted: 2020-11-06 16:12
by jsetzer
At least there is a double quote missing directly after href=, I think.
Re: Path variable to appgini installation
Posted: 2020-11-06 17:34
by SkayyHH
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
Re: Path variable to appgini installation
Posted: 2020-11-06 18:46
by pbottcher
In which file do you have the code?
Re: Path variable to appgini installation
Posted: 2020-11-06 23:44
by SkayyHH
I need the code in the header-extras.php. Therefore i need the path to the installation directory.
Kai
Re: Path variable to appgini installation
Posted: 2020-11-10 19:45
by SkayyHH
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>