imported_disturbedart
Member
- Messages
- 440
- Reaction score
- 0
- Points
- 16
I am trying to make a drop down menu that is fully dynamic for my website. I have it making drop downs and making a full tree menu. Only problem is i can't put external links in as it wont check if the row['ext'] == 1, i've tried everything i can think of so far. I have given you the full working script with the IF statements but without the check for ['ext'] == 1. I basically need the array to check if ['ext']==1 and if it does to output
and if ['ext'] == 0 to output
Anybody able to shed some light please.
Code:
$html .= "<li>\n <a href='/".$menu['items'][$itemId]['link']."'>".$menu['items'][$itemId]['label']."</a>\n</li> \n";
and if ['ext'] == 0 to output
Code:
$html .= "<li>\n <a href='pages/".$menu['items'][$itemId]['link']."'>".$menu['items'][$itemId]['label']."</a>\n</li> \n";
Anybody able to shed some light please.
Code:
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Build Main Navigation menu and gather page data here -----------------------------------------------------------------------------
$sql = "SELECT id, label, link, parent, page_order, ext FROM content_pages WHERE active='1' ORDER BY page_order ASC ";
$query = mysqli_query($dbc, $sql) or die (mysqli_error($dbc));
// Create a multidimensional array to conatin a list of items and parents
$menu = array(
'items' => array(),
'parents' => array(),
);
// Builds the array lists with data from the menu table
while ($items = mysqli_fetch_assoc($query))
{
// Creates entry into items array with current menu item id ie. $menu['items'][1]
$menu['items'][$items['id']] = $items;
// Creates entry into parents array. Parents array contains a list of all items with children
$menu['parents'][$items['parent']][] = $items['id'];
$
}
// Menu builder function, parentId 0 is the root
function buildMenu($parent, $menu, $external)
{
$html = "<ul class='menu sf-js-enabled'>\n";
if ( isset($menu['parents'][$parent]) )
{
$html .= "";
foreach ($menu['parents'][$parent] as $itemId)
{
if(!isset($menu['parents'][$itemId]))
{
$html .= "<li>\n <a href='../pages/".$c.$menu['items'][$itemId]['link']."'>".$menu['items'][$itemId]['label']."</a>\n</li> \n";
}
else
{
$html .= "<li>\n <a href='/".$menu['items'][$itemId]['link']."'>".$menu['items'][$itemId]['label']."</a>\n</li> \n";
}
if(isset($menu['parents'][$itemId]))
{
$html .= "
<li>\n <a href='../pages/".$menu['items'][$itemId]['link']."'>".$menu['items'][$itemId]['label']."</a> \n";
$html .= buildMenu($itemId, $menu);
$html .= "</li> \n";
}
}
$html .= " </ul>\n";
}
$html .= "";
return $html;
}
$nav .= "<div class='bg-2'><div class='container_12'><article class='grid_12'><nav>";
$navend .= "</nav></article></div></div></header>";
mysqli_free_result($query);