Welcome Guest, Not a member yet? Register   Sign In
Only absolute links?

Is it worth the trouble trying to reverse the a/b/c/d/e type of paths with ../../../../, or is it better to just use the absolute links?

Explain with example


It would matter on what you are trying to do. Can you give a specific example? I make use of both absolute and relative paths depending on the situation.

[eluser]Gavin Blair[/eluser]
I always refer to directories with base_url(). For example,

<img src="&lt;?= base_url() ?&gt;images/sweeeeetpic.jpg">

It is an absolute link, but not hard-coded. Sometimes you need to put index.php in there:

<img src="&lt;?= base_url() ?&gt;index.php/images/sweeeeetpic.jpg">

[eluser]Pascal Kriete[/eluser]
I'm with Gavin on this, only I prefer site_url ... It adds index.php automatically Smile .

Sometimes I've to use something like ../../ and not two famous functions.anyways using these is always a good approach.

Can you check your PM.

[eluser]Pascal Kriete[/eluser]
::checks PM ... looks around ... sees nothing new ... comes back confused::


[eluser]Colin Williams[/eluser]
In my experience, hardcoding paths in ANY way is a bad practice, which is why all frameworks have some function to abstract paths. CI's is site_url(), and so that's what I recommend.

In the absence of any dynamic capabilities, I always go with non-domain specific absolute paths (like "/images/frog.jpg")

I am having the same problem. When I try the suggested approach I just get:

Fatal error: Call to undefined function base_url() in C:\wamp\www\CodeIgniter\system\application\views\layout\top.php on line 35

Any suggestion as what I have missed?

[eluser]Pascal Kriete[/eluser]
You have to load the url helper to use the url functions (a good one to autoload Wink ).

Theme © iAndrew 2016 - Forum software by © MyBB