Welcome Guest, Not a member yet? Register   Sign In
Problem with CSS, JS, and IMG directory paths
#11

[eluser]John_Betong[/eluser]
Hi thepyromaniac,

Yes I agree with being much cleaner and have taken your advice and moved the code.

LOCALHOST was used originally to redirect the paths depending on which $_SERVER['SERVER_NAME']. Now LOCALHOST is redundant in index.php. By the way, I currently have three different URL's all accessing the same index.php so it is in a bit of a mess!

My jokes site was my first CI creation and I still use it as a testbed. Needless to say it has some legacy code which one of these fine days I will optimise and make it more MVC compliant.

Cheers,

John_Betong
 
#12

[eluser]noland[/eluser]
Hi all;

my own way to workaround this (allowing dreamweaver to preview the webpages and working ok when executed is described in the following lines.

in the controller I use this code (based on the multiple views post I've seen in this forum):

CONTROLLER

Code:
//we get the webpage code and replace the absolute for my own route
//we write true at the end, so we have the webpage html returned to the 'mywebpage' variable
$mywebpage = $this->load->view('ok', $data,  true);    
        
//here we replace relative routes with my real and good routes (sub folder inside my httproot)
$mywebpage = str_replace("../../../" , "/CodeIgniter_1.5.4/", $mywebpage);                
        
//here we show the page in the screen, with the routes changed correctly
echo $mywebpage;

and now the view code
Code:
<body>
<p><img src="../../../img/advertencia.gif" width="16" height="13"><img src="../../../img/advertencia.gif" width="16" height="13"></p>

as you can see, I use ../../../ to allow dreamweaver to reach ok the photo, but in the controller, i replace that for correct view purposes.

Works pertfectly!

And part II, when the time comes to show an include correctly (it's a little bit absurd this code, but works perfectly Smile )

Code:
&lt;?php
    if (true != true)    {
?&gt;
  &lt;?php
    include("../../../include/menu.php");    
?&gt;
  &lt;?php
    }    else    {    include("include/menu.php");        }
?&gt;

it allows dreamweaver to show me the menu correctly.

In fact this condition is always conducted; the false "if" is only for dreamweaver correctly view purposes.

should be very easy for everyone to convert this process in a processing class for dreamweaver and other IDES Smile

Hope this help! it helps me a lot!!! Smile
#13

[eluser]Unknown[/eluser]
Hi Noland,
your solution is only for address as:
Code:
http://www.your-domain.com/index.php/controller/method
but for adress with 3 segment after index.php:
Code:
http://www.your-domain.com/index.php/controller/method/next_seg
or
Code:
http://www.your-domain.com/index.php/controller/method/next_seg/and_next
... is it useless.




Theme © iAndrew 2016 - Forum software by © MyBB