Question about @BASE variable

69 views
Skip to first unread message

stevedoe

unread,
Dec 24, 2018, 2:47:05 PM12/24/18
to f3-fra...@googlegroups.com
Hello,

I am quite new to web programming in general, so maybe I am missing something :)

According to the F3 documentation abut system variables:


BASE
Type: string, Read-only     Default: auto-detected
Path to the index.php main/front controller.

So, I have created a template page like this:

<html lang="en">
<head>
<link rel="icon" href="{{ @BASE }}/app/images/favicon.ico" />
<link rel="stylesheet" href="{{ @BASE }}/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ @BASE }}/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="{{ @BASE }}/css/theme-cfm.css">
<link rel="stylesheet" href="{{ @BASE }}/css/jquery-ui.css">
<link rel="stylesheet" href="{{ @BASE }}/css/bootstrap-confirm-delete.css">
<link rel="stylesheet" href="{{ @BASE }}/css/calendar.css">

<script type="text/javascript" src="{{ @BASE }}/js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="{{ @BASE }}/js/jquery-ui.js"></script>
<script type="text/javascript" src="{{ @BASE }}/js/bootstrap.js"></script>
<script type="text/javascript" src="{{ @BASE }}/js/bootstrap-confirm-delete.js"></script>
<script type="text/javascript" src="{{ @BASE }}/js/utils.js"></script>

   </head>
<body>

<div class="container theme-showcase" role="main">
<a href="{{ @BASE }}"><img src="{{ @BASE }}/app/images/mylogo.png" alt="Home" height="60"></a>
</div>
<include href="{{ @content }}" />

<br />
<br />

</body>
</html>

And I set the content in function of the actions I take. 

Everything works fine, I have the images displayed in every page, the CSSs and JavaScripts (Bootstrap, Jquery) available on every page.

However, I was expecting that the link on the image mylogo.png to be the same on every single page, pointing to my virtual host main page: http://calendar:8080
Instead, it points to the curent page each time, for example http://calendar:8080/calendar/12.

The route.cfg file is:

[routes]
GET / = GlobalController->overview
GET /calendar/@id = GlobalController->calendar

The .htacces file:

# Enable rewrite engine and route requests to framework
RewriteEngine On

# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
RewriteBase /

RewriteRule ^(tmp)\/|\.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

And the index.php (situated at the root of my structure):

<?php

$f3=require('lib/base.php');

if ((float)PCRE_VERSION<7.9)
trigger_error('PCRE version is out of date');

// Load configuration
$f3->config('config/config.cfg');
$f3->config('config/routes.cfg');

$f3->run();

?>

Currently I am developing on Windows 10x64, WAMP Server 3.1.6, Apache Version 2.4.33, PHP Version: 7.0.33 (I have tried with 7.2.13 as well) and F3 version 3.6.4.

So, my question is again: what am I missing?

Thank you in advance for your help!


richgoldmd

unread,
Dec 24, 2018, 5:00:49 PM12/24/18
to Fat-Free Framework
That’s very strange. Is the template code above a direct copy of your template? If not can you copy and paste the relevant section?

richgoldmd

unread,
Dec 24, 2018, 5:02:57 PM12/24/18
to Fat-Free Framework
On second thought, this is normal browser behavior if the href (and henc BASE) is empty. Can you try

href=“{{ @BASE }}/“
Note the trailing slash.

richgoldmd

unread,
Dec 24, 2018, 5:07:49 PM12/24/18
to Fat-Free Framework
P.S. BASE does not include the domain. If you want the domain in the link you can use HOST or hard code it.

href=“//{{ @HOST }}/{{ @BASE }}”

stevedoe

unread,
Dec 25, 2018, 6:24:27 AM12/25/18
to Fat-Free Framework
This did the trick! Thank you very much!

And Happy Holidays!
Reply all
Reply to author
Forward
0 new messages