<?php require_once 'protect.php'; ?>
<?php if ($pagename=='items.php' AND $type!=4) { ?><div class="menuitem">
<?php
$result30 = $mysqli->query("SELECT * FROM categories WHERE parent=$pid AND parent>0 AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result30->fetch_array()) {
$cid=$row['insert_id'];
$ccategory=$row['name'];
$cpage=$row['page'];

$result31 = $mysqli->query("SELECT id FROM items WHERE category_id=$cid AND section_id=$secid AND lang_id=$lang AND publish='yes'");
$nrrows31 = mysqli_num_rows($result31);
?>
<?php if  ($nrrows31>0) {?><a href="<?php echo $cpage ?>" <?php if ($cid==$catid) { echo 'class="links2b"'; } else { echo 'class="links2"';	}?>>&raquo; <?php echo $ccategory ?></a> &nbsp; <?php } ?>
<?php } ?>
</div><?php } ?>
<?php if ($pagename=='item.php') { ?><div class="menuitem">
<?php
$result31 = $mysqli->query("SELECT id FROM items WHERE category_id=$catid AND section_id=$secid AND page_id>0 AND lang_id=$lang AND publish='yes'");
$nrrows31 = mysqli_num_rows($result31);
?>
<?php if  ($nrrows31<20) {?>
<?php
$result30 = $mysqli->query("SELECT * FROM items WHERE category_id=$catid AND section_id=$secid AND page_id>0 AND lang_id=$lang AND publish='yes' ORDER BY priority");
$nrrows30 = mysqli_num_rows($result30);
while($row = $result30->fetch_array()) {
$itemid=$row['insert_id'];
$pageid=$row['page_id'];
$pageitem=$row['page'];
if ($itempage==1) { $siteitem=$pageitem; }
$pagesiteitem=$siteitem.".".$pageid;
$item=$row['name'];
?>
<a href="<?php echo $pagesiteitem ?>" <?php if ($itemid==$id) { echo 'class="links2b"'; } else { echo 'class="links2"';	}?>>&raquo; <?php echo $item ?></a> &nbsp; 
<?php } ?>
<?php }else{?>
<?php
$result30 = $mysqli->query("SELECT * FROM categories WHERE parent=$parent AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result30->fetch_array()) {
$cid=$row['insert_id'];
$ccategory=$row['name'];
$cpage=$row['page'];

$result32 = $mysqli->query("SELECT id FROM items WHERE category_id=$cid AND section_id=$secid AND lang_id=$lang AND publish='yes'");
$nrrows32 = mysqli_num_rows($result32);
?>
<?php if  ($nrrows32>0) {?>
<a href="<?php echo $cpage ?>" <?php if ($cid==$catid) { echo 'class="links2b"'; } else { echo 'class="links2"'; }?>>&raquo; <?php echo $ccategory ?></a> &nbsp; 
<?php } ?>
<?php } ?>
<?php } ?>
</div><?php } ?>