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

[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?
#2

[eluser]Yash[/eluser]
Explain with example
#3

[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.
#4

[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">
#5

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

[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.
#7

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

:-)
#8

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

[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?
#10

[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