Liz Liz - 5 months ago 34
PHP Question

how to link back to index.php in the fat free framework

I have created some routes with associated html links and they all work fine, except the homepage route (link).

So when i press on the home link to go back to index.php, it does not work.

I have already tried using a slash as key in my array, but that takes me too far back.

What can i put in the array so it links back to index.php?

here is the code in index.php

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

$f3->set('AUTOLOAD', 'model/');

$f3->set('UI','view/');

$f3->route('GET /', 'content->home');

$f3->route('GET /about','content->about');

$f3->route('GET /jobs','content->jobs');

$f3->set('menu',array(''=>'home','about'=>'about','jobs'=>'jobs'));

$f3->run();


here is the code in my template header.htm

<repeat group="{{ @menu }}" key="{{ @key }}" value="{{ @link }}">
<a href="{{@key}}" {{ @pagetitle==@link?' class="active" ':' ' }} >{{ @link }}</a>
</repeat>

Liz Liz
Answer Source

After taking a good look at the fat free framework documentation i found this:

$f3->get('BASE');

This is a ff global that gets you back to index.php

I've saved it in my own variable like so:

$f3->set('home',$f3->get('BASE'));