Skip to main content
added 14 characters in body
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 25
  • 82

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

EDIT 2 you have an error in your code

<?php
$groups = $this->getGroups();
$mySelectedGroups = array('2''1403', '4''1404', '1405'); // this is the group entity_id from database
?>

<!-- tab navigation -->
<ul id="tabs" class="nav nav-tabs">
    <?php 
    $navI = 1;
    foreach ($groups as $group) :
        if (in_array($group, $mySelectedGroups)):
            if ($group->hasProducts()): ?>
                <li <?php if ($navI == 1) { ?> class="active" <?php } ?> >
                    <a href="#<?php echo $group->getId(); ?>"
                       data-toggle="tab">
                        <?php echo $group->getName(); ?>
                        &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                    </a>
                </li>
                <?php $navI++; ?>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

EDIT 2 you have an error in your code

<?php
$groups = $this->getGroups();
$mySelectedGroups = array('2', '4'); // this is the group entity_id from database
?>

<!-- tab navigation -->
<ul id="tabs" class="nav nav-tabs">
    <?php 
    $navI = 1;
    foreach ($groups as $group) :
        if (in_array($group, $mySelectedGroups)):
            if ($group->hasProducts()): ?>
                <li <?php if ($navI == 1) { ?> class="active" <?php } ?> >
                    <a href="#<?php echo $group->getId(); ?>"
                       data-toggle="tab">
                        <?php echo $group->getName(); ?>
                        &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                    </a>
                </li>
                <?php $navI++; ?>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

EDIT 2 you have an error in your code

<?php
$groups = $this->getGroups();
$mySelectedGroups = array('1403', '1404', '1405'); // this is the group entity_id from database
?>

<!-- tab navigation -->
<ul id="tabs" class="nav nav-tabs">
    <?php 
    $navI = 1;
    foreach ($groups as $group) :
        if (in_array($group, $mySelectedGroups)):
            if ($group->hasProducts()): ?>
                <li <?php if ($navI == 1) { ?> class="active" <?php } ?> >
                    <a href="#<?php echo $group->getId(); ?>"
                       data-toggle="tab">
                        <?php echo $group->getName(); ?>
                        &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                    </a>
                </li>
                <?php $navI++; ?>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>
added 1072 characters in body
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 25
  • 82

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

EDIT 2 you have an error in your code

<?php
$groups = $this->getGroups();
$mySelectedGroups = array('2', '4'); // this is the group entity_id from database
?>

<!-- tab navigation -->
<ul id="tabs" class="nav nav-tabs">
    <?php 
    $navI = 1;
    foreach ($groups as $group) :
        if (in_array($group, $mySelectedGroups)):
            if ($group->hasProducts()): ?>
                <li <?php if ($navI == 1) { ?> class="active" <?php } ?> >
                    <a href="#<?php echo $group->getId(); ?>"
                       data-toggle="tab">
                        <?php echo $group->getName(); ?>
                        &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                    </a>
                </li>
                <?php $navI++; ?>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

EDIT 2 you have an error in your code

<?php
$groups = $this->getGroups();
$mySelectedGroups = array('2', '4'); // this is the group entity_id from database
?>

<!-- tab navigation -->
<ul id="tabs" class="nav nav-tabs">
    <?php 
    $navI = 1;
    foreach ($groups as $group) :
        if (in_array($group, $mySelectedGroups)):
            if ($group->hasProducts()): ?>
                <li <?php if ($navI == 1) { ?> class="active" <?php } ?> >
                    <a href="#<?php echo $group->getId(); ?>"
                       data-toggle="tab">
                        <?php echo $group->getName(); ?>
                        &nbsp;<i style="display: none;" class="text-danger error_glyph_<?php echo $group->getId(); ?> fa fa-exclamation-circle" aria-hidden="true"></i>
                    </a>
                </li>
                <?php $navI++; ?>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>
added 244 characters in body
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 25
  • 82

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

I don't know if this is exactly what you want but if you want to set the groups manually, you have to put them in an array something like this:

$groups = array('group1', 'group2', ...);

foreach ($groups as $group) :
...

EDIT:

$groups = $this->getGroups(); // your groups
$mySelectedGroups = array('group1', 'group2', ...);

foreach($group as $group) {
    if (in_array($group, $mySelectedGroups)) {
    //...
    }
}
Source Link
PЯINCƎ
  • 11.7k
  • 3
  • 25
  • 82
Loading