Jump to content

Recommended Posts

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!
[code]<?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>[/code]

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; /* */

Link to comment
https://forums.phpfreaks.com/topic/21081-changing-the-2end-level/
Share on other sites

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)...
[code]
<ul>
<li>Item</li>
<li>Item</li>
<li>item
<ul>
  <li>Sub Item</li>
  <li>Sub Item</li>
</ul>
</li>
<li>Item</li>
</ul>
[/code]

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
}
 
Something like this should do it (I know it is ugly): [code]<?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>[/code]

You just need to style it better though.
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;

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

Thanks for your patience.

  • 1 month later...
[img]http://www.justcaroline.co.uk/images/navbar.gif[/img]

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.