Jump to content


Photo

changing the 2end level


  • Please log in to reply
14 replies to this topic

#1 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 17 September 2006 - 06:15 PM

I’m sorry if the is comes over a little confused, I am a total newbie!

At the moment I have a Navigation bar list put into boxes with css, and it works fine.

But what I want to do is make the second level, bulleted and not in boxes, so it is easier to see that they are sub levels.

Any help would be great. Sorry if I gave too much code, not sure what you needed too see.

Thanks!
<?php
if (!defined('WEB_ROOT')) {
	exit;
}

// get all categories
$categories = fetchCategories();

// format the categories for display
$categories = formatCategories($categories, $catId);
?>
<ul>
  <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>">All 
    Products </a></li>
<?php
foreach ($categories as $category) {
	extract($category);
	// now we have $cat_id, $cat_parent_id, $cat_name
	
	$level = ($cat_parent_id == 0) ? 1 : 2;
    $url   = $_SERVER['PHP_SELF'] . "?c=$cat_id";

	// for second level categories we print extra spaces to give
	// indentation look
	if ($level == 2) {
		$cat_name = '&nbsp; &nbsp; &raquo;&nbsp;' . $cat_name;
	}
	
	// assign id="current" for the currently selected category
	// this will highlight the category name
	$listId = '';
	if ($cat_id == $catId) {
		$listId = ' id="current"';
	}
?>
<li<?php echo $listId; ?>><a href="<?php echo $url; ?>"><?php echo $cat_name; ?></a></li>
<?php
}
?>
</ul>

css...

//#leftnav {
//width: 150px;
//font-size: 12px;
//vertical-align: top;
//font-size: 85%;
//font-family: Arial, Helvetica, sans-serif;
//color: #000000;
}

ul, ol {
font-family: Georgia, "Times New Roman", Times, serif;
}

#leftnav a {
padding: 3px;
display: block;
border: 1px solid #000099;
text-decoration: none;
line-height: 1em;
width: 150px;
background-color: #7AD8CE;
}

#leftnav a:link, #leftnav a:visited {
color: #003399;
}

#leftnav a:hover, #leftnav a:active {
color: #FFFFFF;
background-color: #6699CC;
border: 1px solid #000;
}

#leftnav ul {
/*/*/padding: 0em;
margin-left: 0em;
margin-right: 0em;
list-style-type: none; /* */
}

#leftnav li {
/*/*/margin: 0px 0px 6px 0px; /* */
}

#current a {
color: #FFFFFF !important;
/*/*/background-color: #99CCFF!important;
border: 2px solid #003399!important; /* */



#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 September 2006 - 10:34 AM

without reading all that you can use this

ul {
some decalrations that apply to top level
}

ul ul {
some declarations that apply to an unordered list inside an unordered list.
}
follow me on twitter @PHPsycho

#3 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 September 2006 - 12:43 PM

ToonMariner, thanks for the help.

I'm sorry for being so stupid, but this is the first website i have ever made.

Where do I put them? *ducks all vertual slaps, rotten Tomatoes etc*

#4 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 September 2006 - 01:01 PM

In your style sheet.....
follow me on twitter @PHPsycho

#5 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 September 2006 - 01:18 PM

how does that then transfer to the code page?

#6 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 September 2006 - 03:03 PM

Your html will look like something like this (not checked your code - if your code does not create this change it so it does - that is good practice for html)...
<ul>
 <li>Item</li>
 <li>Item</li>
 <li>item
 <ul>
  <li>Sub Item</li>
  <li>Sub Item</li>
 </ul>
 </li>
 <li>Item</li>
</ul>

and in your style sheet is the ul ul bit.

If this is a navigation type list then stick ALL the html for the unordered lists inside a div with id="nav"

then you can further refine you css to

#nav ul {
// attributes for top level list
}

#nav ul ul {
// attributes for sub lists
}
 
follow me on twitter @PHPsycho

#7 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 September 2006 - 03:19 PM

Thank you ;D

#8 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 19 September 2006 - 03:12 PM

Sorry! thought I had it, but I'm still stuck.

#9 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 September 2006 - 06:34 PM

Something like this should do it (I know it is ugly):
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Test</title>
<style type="text/css">
ul
{
	
	background-color: blue;
}

ul ul
{
	background-color: green;
}

ul ul ul
{
	background-color: red;
}

ul ul ul ul
{
	background-color: yellow;
}
</style>
</head>
<body>

<ul>
	<li>
		test
	</li>
	<li>
		test
		</li>
	<li>
		<ul>
			<li>test</li>
			<li>test</li>
			<li>
				<ul>
					<li>test</li>
					<li>test</li>
					<li>
						<ul>
						<li>test</li>
						<li>test</li>
						</ul>
					</li>
				</ul>
			</li>
		</ul>
	</li>
</ul>

</body>
</html>

You just need to style it better though.

#10 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 September 2006 - 12:03 PM

Ok, when I look at the source code on my website, it is laid out like the above.
But it is still not working.

Maybe I made a mistake and it is the php code?

Changes made


#leftnav ul ul {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
list-style-position: outside;
list-style-type: disc;

<ul>
<li<?php echo $listId; ?>><a href="<?php echo $url; ?>"><?php echo $cat_name; ?></a></li>
</ul>

Thanks for your patience.



#11 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 October 2006 - 02:38 PM

Hi .. sorry me again :-[
Can anybody help?
Thanks

#12 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 October 2006 - 02:41 PM

You will need to set the margin of your sub list li elements! the top level has margin & paddin 0 this is inherited by child elements so make sure you give ul ul li{ margin: 0 0 0 5px;}
follow me on twitter @PHPsycho

#13 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 October 2006 - 03:22 PM

Thank you
The sub level is still in a blue boxes (same as the top level).
It all works fine I would just like the sub levels to be different from the main levels, but nothing I have tried seems to work.???


#14 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 October 2006 - 03:26 PM

I suspect you are setting the background colour of the a tag still - which will override any li or ul background colors.
follow me on twitter @PHPsycho

#15 kit

kit
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 October 2006 - 03:45 PM

Posted Image

This is what it looks like.
yes I think the bg a tag is the problem, it is the colour that makes it look like its in a light blue box. I have tried, changing this but when I put the bg colur on the ul or ul ul it doesnt put each title in a seperate box just one big one.

Maybe I should just give up. Can anyone recommend a template or tutorial I can use for the same effect.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users