Welcome Guest, Not a member yet? Register   Sign In
Trouble with getting a menu to pick up style sheet and images.
#1

[eluser]The Beginner[/eluser]
Hi all, I am beginning my first project in CI and I went through the BLOG tutorial and I really like the way everything works. When I started trying to implement my dynamic CSS menu I ran into problems. I have pasted the view file code below. It does not seam to be picking up the "menu_style.css" file which in turn should be picking up the appropriate images. Am I missing something? This works fine as a stand along html file. Is it a path issue? I have tried moving the css file and images to several different directories with no success. Any suggestions would be greatly appreciated. :cheese:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/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;?php echo $title; ?&gt;&lt;/title&gt;
&lt;link rel="stylesheet" href="menu_style.css" type="text/css" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php echo $htmlstring; ?&gt;
<div>
<ul class="menu">
<li class="top"><a href="#" class="top_link"><span>Sample Menu</span></a></li>
<li class="top"><a href="#" class="top_link"><span>Sample Menu This is some longer text</span></a>
<ul class="sub">
<li><a href="#">Sample Menu This is some longer text</a></li>
<li><a href="#">Sample Menu</a></li>
<li><a href="#">Sample Menu</a></li>
<li><a href="#">Sample Menu</a></li>
<li><a href="#">Sample Menu</a></li>
</ul>
</li>
<li class="top"><a href="#" class="top_link"><span>Sample Menu</span></a>
<ul class="sub">
<li><a href="#">Sample Menu This is some longer text</a></li>
<li><a href="#">Sample Menu</a></li>
<li><a href="#">Sample Menu</a></li>
<li><a href="#">Sample Menu</a></li>
</ul>
</li>
<li class="top"><a href="#" class="top_link"><span>Sample Menu</span></a></li>
<li class="top"><a href="#" class="top_link"><span>Sample Menu</span></a></li>
</ul>
</div>
<p>&lt;?php echo anchor('blog/', 'Back To Blog'); ?&gt;</p>
&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]boony[/eluser]
Hi,

Welcome to CI community. Without taking a close look I would suggest it is most likely a path issue. Place this a call to the base url...as below and it should work.

[quote

&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;link rel="stylesheet" href="&lt;?=base_url()?&gt;menu_style.css" type="text/css" /&gt;
[/quote]

Have a look at the URL helper in the user guide for a more detailed explanation. Oh and don't forget to include the url helper in the controller as well... ;-P
#3

[eluser]BrianDHall[/eluser]
If you use Chrome or any of the developer extentions to Firefox (like Firebug) you can check to see if your CSS is actually being included. I think boony is correct and its just a path issue, but if not you'll need to see just what is going on and a smart browser is the best way to see.

If that isn't working my next guess is an htaccess issue - in which case paste the url of where you think your css file is in your browser. Do you get to access it, or no? If not then you have to see whats up.

If you can and you aren't getting it to pull in correctly using base_url, use an absolute (http://...full path) path to your file and see if that works.

Note that all paths are relative to the "front-controller" of index.php in the main directory, NOT the controller you use to control your pages.
#4

[eluser]boony[/eluser]
Hi again,

all the suggestions by Brian are good stuff. But I scrolling down a couple of topics I came across this
Code:
http://ellislab.com/forums/viewthread/129877/
which has some valuable info that is well worth investigating...
#5

[eluser]The Beginner[/eluser]
Hi guy's, Thanks for the responce.

boony, I pasted in your suggestion slightly modified and whola, it worked. thanks, bunches.

"&lt;link rel=“stylesheet” href=”&lt;?php echo base_url();?&gt;menu_style.css” type=“text/css” /&gt; "




Theme © iAndrew 2016 - Forum software by © MyBB