Welcome Guest, Not a member yet? Register   Sign In
Img() with link and rollover
#11

[eluser]elaniobro[/eluser]
Yes, that is correct. However when I do put that as my base URL, all the links to my images/css/js etc.. become broken.

Code:
$config['base_url']    = "http://www.example.com/5/";

My site is littered with 404's

Code:
http://www.example.com/5/com/css/accordion.css

Which in theory should be correct.

Here is how it is linked in my header:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;&lt;?= $title ?&gt;&lt;/title&gt;
&lt;link rel="apple-touch-icon" href="&lt;?= base_url();?&gt;img/iphone.png"/&gt;
&lt;link type="text/css" href="&lt;?= base_url();?&gt;com/css/global.css" rel="stylesheet" media="screen" /&gt;
&lt;link type="text/css" href="&lt;?= base_url();?&gt;com/css/&lt;?= $page ?&gt;.css" rel="stylesheet" media="screen" /&gt;
&lt;link type="text/css" href="&lt;?= base_url();?&gt;com/css/accordion.css" rel="stylesheet" media="screen" /&gt;

[removed][removed]
&lt;/head&gt;


The base_url in the config sets the absolute path. And the index.php file sets the routes for application and system which are affixed the base path.

So what am I doing wrong in my scenario? Should I not be using the base_url() function to set the path with?
#12

[eluser]elaniobro[/eluser]
The css/images only gets pulled in correctly if it is linked to with system/application in the URL.

Works:
Code:
http://www.example.com/5/system/application/com/css/global.css

Does not work:
Code:
http://www.example.com/5/com/css/global.css
#13

[eluser]danmontgomery[/eluser]
Where is the physical file? in system/application/com/css? If that's the case you can use APPPATH instead of base_url(), but my suggestion is to move assets out of system/ so they can be more easily referenced.
#14

[eluser]elaniobro[/eluser]
Yes that is where the physical file is located, as indicated in the URL in my above post. As for moving the assets, just so I am clear you are suggesting the following file structure?

Code:
http://www.example.com/5/system
http://www.example.com/5/com
                        /css
                        /js
                        /img
http://www.example.com/5/application
                                    /views
                                    /controller
                                    /config
                                    /etc.....

So the only thing that would sit at the same level as system would be my img and com folder?
#15

[eluser]elaniobro[/eluser]
Ok, moving my assets i.e. 'com/js, com/css, com/etc...' & 'img' folders out of my application like you said did the trick, now everything appears to be working properly. Thanks for the help and patience Noctrum & Jedd
#16

[eluser]danmontgomery[/eluser]
Yep, that's exactly how I would have done it... Cheers.
#17

[eluser]elaniobro[/eluser]
Alright, back to the orginal question at hand.

I've tried using the anchor() to then use CSS for the rollovers, but nothing is appearing!

Here is the code to create the <a> link
Code:
<div class="post-readmore">
                        &lt;?= anchor('/thoughts/more/'.$row->id,'<span>Read More</span>',array('class'=>'readmore-link'));?&gt;
                    </div>

and the CSS to stylize it:
Code:
.post-readmore
{
    width: 18px;
    height:14px;
    margin:8px 0 50px 0;
    border:1px solid #f09;
}
span
{
    display:none;    
}
.readmore-link:link{
    background: url('../../img/thoughts/readmore_a.jpg') no-repeat;
}
.post-readmore a:hover{
    background-image: url('../../img/thoughts/readmore_b.jpg') no-repeat;    
}
#18

[eluser]elaniobro[/eluser]
Phew!

Finally got it here is the markup for those interested.

Code:
&lt;?= anchor('/thoughts/more/'.$row->id,
                                img(array(
                                          'src'=>'img/thoughts/readmore_a.jpg',
                                          'id'=>'readMore',
                                          'border'=>'0',
                                          'alt'=>'Read More'
                                          )
                                    ),
                                array(                                          
                                      'onmouseover'=>'readMore.src='."'".base_url().'img/thoughts/readmore_b.jpg'."'".';'.'"',
                                      'onmouseout'=>'readMore.src='."'".base_url().'img/thoughts/readmore_a.jpg'."'".';'.'"'
                                      )
                                );
                     ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB