I'd like to add condition to my code so that after click on label it link me to other page. Now this code link to other article on the website. So I guess what should I add to get from my label to other page.
Thank you for answers! My code is below:
<ul class="nav nav-tabs aboutUsTabs nav-justified" role="tablist">
<?php foreach ($this->items as $key=>$item ){
if($item['children']){ ?>
<li role="presentation" class="<?php if($item['menu']->id==$this->pageId || $item['menu']->id==$this->parentId){ echo 'active'; } ?>"><a href="#about-us-page-<?php echo $item['menu']->id;?>" aria-controls="about-us-page-<?php echo $item['menu']->id;?>" role="tab" data-toggle="tab"><?php echo $item['menu']->title;?></a></li>
<?php }else{ ?>
<li role="presentation" class="<?php if($item['menu']->id==$this->pageId || $item['menu']->id==$this->parentId){ echo 'active'; } ?>"><a href="<?php echo $item['menu']->path;?>" aria-controls="about-us-page-<?php echo $item['menu']->id;?>"><?php echo $item['menu']->title;?></a></li>
<?php } ?>
<?php } ?>
</ul>
All this start/stop of PHP code hurts my eyes! Anyways, linking to other pages is done with <a href=""></a>
tags. Not quite sure I understand your question, but you could (if you mean labels for form elements) do something like this;
<label for=""> <a href="SOME_PAGE.html"> Something Meaningful </a> </label>
I'm sorry, but I took the liberty to clean up your code a little. Hopefully this will make it more readable;
<ul class="nav nav-tabs aboutUsTabs nav-justified" role="tablist">
<?php
foreach ($this->items as $key=>$item ){
$active = NULL;
if($item['menu']->id==$this->pageId || $item['menu']->id==$this->parentId){
$active = 'active';
}
$menu = NULL;
if($item['menu']->id==$this->pageId || $item['menu']->id==$this->parentId){
$menu = 'active';
}
if($item['children']){
echo'<li role="presentation" class="'.$active.'">
<a href="#about-us-page-'.$item['menu']->id.'" aria-controls="about-us-page-'.$item['menu']->id.'" role="tab" data-toggle="tab">'.$item['menu']->title.'</a>
</li>';
}else{
echo'<li role="presentation" class="'.$menu.'">
<a href="'.$item['menu']->path.'" aria-controls="about-us-page-'.$item['menu']->id.'">'.$item['menu']->title.'</a>
</li>';
}
}
?>
</ul>
For your comment question, if you know what item needs a different value, it could be the title
f.ex. then you can check against that value and change the output of your element. Maybe something like;
if($item['children']){
if($item['title'] == 'Unique Identifier for your element') {
// In here you could manipulate the output of that one item you want to exclude/change
} else {
// Your normal output
echo'<li role="presentation" class="'.$active.'">
<a href="#about-us-page-'.$item['menu']->id.'" aria-controls="about-us-page-'.$item['menu']->id.'" role="tab" data-toggle="tab">'.$item['menu']->title.'</a>
</li>';
}else{ ... }
And even better would be to perform the check beforehand, so maybe something like;
$link = '#about-us-page-'.$item['menu']->id;
if($item['title'] == "That identifier") {
$link = 'somethingElse';
}
and then change the value of your href
tag to;
<a href="'.$link.'" aria-controls="about-us-page-'.$item['menu']->id.'" role="tab" data-toggle="tab">'.$item['menu']->title.'</a>