Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

wrong generated links

I am testing localhost/whitespace/book24

I am having issue, while creating the links i.e. the links are generating as localhost/assests/css/

I have set url in my service.php

$config->application->baseUri = '/whitespace/book24/';

$di->set('url', function () use ($config) {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri($config->application->baseUri);
    return $url;
}, true);

css links in volt file.

<link href="/assests/css/style.css">

can anyone helps ?

//Setting a relative base URI
$url->setBaseUri('/invo/');
//Setting a full domain as base URI
$url->setBaseUri('//my.domain.com/');
//Setting a full domain as base URI
$url->setBaseUri('http://my.domain.com/my-app/');

echo $url->get("controller/action");

http://stackoverflow.com/questions/21856287/how-to-get-full-path-url-in-phalconphp



30.7k

Hi,

for loading css files:

use tag service: https://docs.phalconphp.com/en/latest/reference/tags.html#stylesheets

or much better if you have a bunch of static assets like css and js: phalcon's asset manager: https://docs.phalconphp.com/en/latest/reference/assets.html

Hey, Thanks for telling about assets manager. but the problem of the link is all over the app. that is if i define anchor tag like this <a href="/contact/index"> it goes to localhost/contact/index and not localhost/whitespace/book24/contact/index.



30.7k
Accepted
answer

hi,

use tag helper (for loading css, but also for creating links: https://docs.phalconphp.com/en/latest/reference/tags.html#generating-links)

Hey, Thanks for telling about assets manager. but the problem of the link is all over the app. that is if i define anchor tag like this <a href="/contact/index"> it goes to localhost/contact/index and not localhost/whitespace/book24/contact/index.

That's normal behaviour of HTML relative links (anchors). Try to ommit the leading slash / and see the difference.

Just follow what others told you here already if you want to do it right.