CodeIgniter Forums
myth: links in views are displayed wrong - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: myth: links in views are displayed wrong (/showthread.php?tid=75739)



myth: links in views are displayed wrong - muuucho - 03-11-2020

I am trying to get familiar with myth/auth. I have installed it and when I visit the login page, the links in that view are missing my project's name in the url: Register goes to 'localhost/register' instead of 'localhost/my-project/register'.

I guess the problem is my setup.
In app.php I have set 
Code:
public $baseURL = 'http://localhost/my-project/';
public $indexPage = '';
I've also moved index and .htaccess to the root. In index.php I 've set:
Code:
$pathsPath = FCPATH . 'app/Config/Paths.php';
In the view the link holds a route_to() method. About there I am lost.


RE: myth: links in views are displayed wrong - muuucho - 03-12-2020

Update: I run the project above on my Apache server. If I instead run it on PHP's built in server from the root of my project (c:xampp/localhost/htdocs/my-project) I get rid of the subfolder problem and route_to() is working without being rapped in base_url().

Still, shouldn't route_to() use baseURL from config?


RE: myth: links in views are displayed wrong - InsiteFX - 03-12-2020

The route_to uses a named route.

See my route for dashboard below, ['as' => 'dashboard']

PHP Code:
$routes->get('dashboard''Admin::dashboard', ['as' => 'dashboard']); 

So my route_to would be in html like below.

PHP Code:
<?= route_to('dashboard'?>



RE: myth: links in views are displayed wrong - muuucho - 03-12-2020

OK, then is Myth missing the routes?


RE: myth: links in views are displayed wrong - kilishan - 03-12-2020

What version of CodeIgniter are you using?


RE: myth: links in views are displayed wrong - muuucho - 03-13-2020

(03-12-2020, 01:41 PM)kilishan Wrote: What version of CodeIgniter are you using?
I'm using 4.0.2


RE: myth: links in views are displayed wrong - muuucho - 03-14-2020

(03-12-2020, 05:07 AM)InsiteFX Wrote: The route_to uses a named route.

See my route for dashboard below, ['as' => 'dashboard']

PHP Code:
$routes->get('dashboard''Admin::dashboard', ['as' => 'dashboard']); 

So my route_to would be in html like below.

PHP Code:
<?= route_to('dashboard'?>
Yes, Lonnie has routes like:

Code:
$routes->get('register', 'AuthController::register', ['as' => 'register']);
The problem is that  when you have the project installed in subfolder (like localhost/my_project) the part "my-project" isn't included in the URI. Even if I have "http://localhost/my-project" it in my baseURL in config/app.php