CodeIgniter Forums
Only absolute links? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Only absolute links? (/thread-10511.html)

Pages: 1 2


Only absolute links? - El Forum - 08-02-2008

[eluser]Unknown[/eluser]
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?


Only absolute links? - El Forum - 08-02-2008

[eluser]Yash[/eluser]
Explain with example


Only absolute links? - El Forum - 08-02-2008

[eluser]valarkin[/eluser]
Phristen:

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.


Only absolute links? - El Forum - 08-02-2008

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

Code:
<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:

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



Only absolute links? - El Forum - 08-02-2008

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


Only absolute links? - El Forum - 08-02-2008

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

@inparo
Can you check your PM.


Only absolute links? - El Forum - 08-02-2008

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

:-)


Only absolute links? - El Forum - 08-02-2008

[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")


Only absolute links? - El Forum - 08-11-2008

[eluser]Tommy_DK[/eluser]
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?


Only absolute links? - El Forum - 08-11-2008

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