News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

help with tabs?

Started by Kindred, December 08, 2020, 03:24:46 PM

Previous topic - Next topic

Kindred

https://test2.turtleshellprod.com/index.php


foreach ($context['categories'] as $category_tab)
{
// If theres no parent boards we can see, avoid showing an empty category
if (empty($category_tab['boards']))
continue;
     
echo '
<input class="cat_tab" id="category_', $category_tab['id'], '" type="radio" name="tabs" checked="', ($category_tab['id'] = 1 ? 'checked' : '') ,'">
            <label for="category_', $category_tab['id'], '" class="cat_tab"><h3 class="catbg">', $category_tab['name'], '</h3></label>';
    }
 
foreach ($context['categories'] as $category)
{

echo'
<div class="cat_board_content">
                <div id="category_', $category['id'], '_boards">
    ', !empty($category['description']) ? '
<div class="cat_bar"><div class="desc">' . $category['description'] . '</div></div>' : '', '';
 



so, if I use this code...   the $category['id'] gets stuck =1.
the other category names names display, but the id variable doesn't update with the rest of the array...

The goal here is to set the first tab as the default loaded tab, but allow other tabs to be clicked to reveal their content...
With no "default/checked" set, the display defaults to reveal the last tab in the set...

any ideas?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SychO

You're not comparing when doing: $category_tab['id'] = 1
= is an assignment operator, use == or === for strict comparison

that should be the problem, I think.. at least at a first glance
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Kindred

OOF!   I should know that by now.


So, using == did indeed correct the problem with the ID getting stuck.

However, strangely enough -- the CSS does not appear to be respecting the "checked" value...

When you go to the page, category 1 is indeed marked as checked. However, the page displays category 4 (which is the last loaded category)


so, now it seems less of a php coding issue and some sort of html/css logic issue.

blerg.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SychO

try changing checked="', ($category_tab['id'] = 1 ? 'checked' : '') ,'" to just ', ($category_tab['id'] = 1 ? 'checked' : '') ,'

HTML wise I believe there is no difference between checked="checked" and just checked (which amounts to checked="")

so your inputs are still all checked
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Kindred

That did it...    odd.

checked="checked" was supposed to be better for compliance...

cool...    SMF 2.1 tabbed categories and info center with no javascript at all and only minor changes to BoardIndex.template.php and additions to index.css...  reduce the real estate!
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SychO

oh damn, I thought there was some javascript involved, but yeah it's pure HTML+CSS

that's awesome, goes to show how powerful they can be!
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Advertisement: