Setting "collapsible" catagories to "collapsed" by default?

Started by Jon Just Jon, September 05, 2006, 06:50:28 PM

Previous topic - Next topic

Jon Just Jon

SMF Version: SMF 1.1 RC3
Hi Guys.

I am aware that members can collapse categories etc, but is there a way of making them collasped by default so that when a new member joins all they see are the list of categories?

cat001
cat002
cat003

instead of:

cat001
-- Interesting stuff 001
-- Interesting stuff 002
-- Interesting stuff 003
cat002
-- Really interesting stuff 001
-- Really interesting stuff 002
-- Really interesting stuff 003
cat003
-- I just gotta post in that! 001
-- I just gotta post in that! 002
-- I just gotta post in that! 003

Reason being: I have been doing some user testing, and this group have found it "overwhelming" to be presented with so many boards initially. The Forum has 12 categories, each with 4+ boards, and this is a group with little or no Forum experience, bless em.

So it would be great to have them see just the main categories, then explore while they find their feet. I am doing an introductory PDF with screen shots and all, but even so...

Also I think, visually, it looks quite cool to have just those big coloured bars with the main headings, especially when you have more than a handful of categories.

Thanks in advance.
Luv ya, Luv ya software!

Regards,
Jon.
Love, Peace and...

Jon Just Jon

Is this Impossible?

Or is it just that no one knows?

Cheers.
Love, Peace and...

Harzem

Open BoardIndex.php (in Sources directory), find:

$context['categories'][$row_board['ID_CAT']] = array(

add this before it:

$row_board['isCollapsed'] = $row_board['isCollapsed'] > 0 ? 0 : 1;

This will reverse every setting, which will PROBABLY work as you want.

Jon Just Jon

Thanks HarzeM,

I'll give that a go this evening and post what happens...

"PROBABLY" is a good start!
Love, Peace and...

Jon Just Jon

OK, its a start...

That lil alteration did good of defaulting all the Cats to "Collasped" - But when you click to uncollapse - They don't!  :-\

Oh well, thanks for having a go HarzeM,
I'll keep looking...
Love, Peace and...

Harzem

Ok, now find:

($row_board['isCollapsed'] > 0 ? 'expand' : 'collapse;')

replace:

($row_board['isCollapsed'] <= 0 ? 'expand' : 'collapse;')

Jon Just Jon

#6
That will work then  :-* Marry Me!

OK, so I got over passionate there.. Thanks for your time and effort MarzeM.

(I could see that the href was needing instruction, I just couldn't work out which > or <= or whatever was needed.
so in one stroke you have solved my issue AND given me a great lesson... Many thanks)

So, to summurise


If you want to have Collapsed Catagories "Collapsed" by default when a new member joins up, you need to replace this code in:
Directory > Sources > Boardindex.php

(Remember to do a "save as" thing, and back up your Server version first, in your "BackedUpMyReallyImportantForum" directory.

Personally I keep a clean folder of RC3, and then open from there, do a save as to
> RC3 Changes > Boardindex > Boardindex.php_whywontthebastardmenuesstayup002, etc, then when ready to upload, I can rename within the
> RC3 Changes > Boardindex >
to Boardindex.php
And upload happily to test... joy joy)

Replace this code:

Quote// Haven't set this category yet.
      if (empty($context['categories'][$row_board['ID_CAT']]))
      {
         $context['categories'][$row_board['ID_CAT']] = array(
            'id' => $row_board['ID_CAT'],
            'name' => $row_board['catName'],
            'is_collapsed' => isset($row_board['canCollapse']) && $row_board['canCollapse'] == 1 && $row_board['isCollapsed'] > 0,
            'can_collapse' => isset($row_board['canCollapse']) && $row_board['canCollapse'] == 1,
            'collapse_href' => isset($row_board['canCollapse']) ? $scripturl . '?action=collapse;c=' . $row_board['ID_CAT'] . ';sa=' . ($row_board['isCollapsed'] > 0 ? 'expand' : 'collapse;') . '#' . $row_board['ID_CAT'] : '',
            'collapse_image' => isset($row_board['canCollapse']) ? '<img src="' . $settings['images_url'] . '/' . ($row_board['isCollapsed'] > 0 ? 'expand.gif" alt="+"' : 'collapse.gif" alt="-"') . ' border="0" />' : '',
            'href' => $scripturl . '#' . $row_board['ID_CAT'],
            'boards' => array(),
            'new' => false
         );
         $context['categories'][$row_board['ID_CAT']]['link'] = '<a name="' . $row_board['ID_CAT'] . '" href="' . (isset($row_board['canCollapse']) ? $context['categories'][$row_board['ID_CAT']]['collapse_href'] : $context['categories'][$row_board['ID_CAT']]['href']) . '">' . $row_board['catName'] . '</a>';
      }

      // If this board has new posts in it (and isn't the recycle bin!) then the category is new.

With this code:

Quote// Haven't set this category yet.
      if (empty($context['categories'][$row_board['ID_CAT']]))
      {
      $row_board['isCollapsed'] = $row_board['isCollapsed'] > 0 ? 0 : 1;
         $context['categories'][$row_board['ID_CAT']] = array(
            'id' => $row_board['ID_CAT'],
            'name' => $row_board['catName'],
            'is_collapsed' => isset($row_board['canCollapse']) && $row_board['canCollapse'] == 1 && $row_board['isCollapsed'] > 0,
            'can_collapse' => isset($row_board['canCollapse']) && $row_board['canCollapse'] == 1,
            'collapse_href' => isset($row_board['canCollapse']) ? $scripturl . '?action=collapse;c=' . $row_board['ID_CAT'] . ';sa=' . ($row_board['isCollapsed'] <= 0 ? 'expand' : 'collapse;') . '#' . $row_board['ID_CAT'] : '',
            'collapse_image' => isset($row_board['canCollapse']) ? '<img src="' . $settings['images_url'] . '/' . ($row_board['isCollapsed'] > 0 ? 'expand.gif" alt="+"' : 'collapse.gif" alt="-"') . ' border="0" />' : '',
            'href' => $scripturl . '#' . $row_board['ID_CAT'],
            'boards' => array(),
            'new' => false
         );
         $context['categories'][$row_board['ID_CAT']]['link'] = '<a name="' . $row_board['ID_CAT'] . '" href="' . (isset($row_board['canCollapse']) ? $context['categories'][$row_board['ID_CAT']]['collapse_href'] : $context['categories'][$row_board['ID_CAT']]['href']) . '">' . $row_board['catName'] . '</a>';
      }

      // If this board has new posts in it (and isn't the recycle bin!) then the category is new.

This is working fine using SMF 1.1 RC3, Default.
No Mods installed.
But I will feed back Sunday 10th Sept as I will be adding Mods to that Forum.
(But I can't see this code affecting - Just playing safe) (and sorry to post a big code "cut and paste" thing, but I find it easier for us Noobs to "c and p" between things we understand... It's a learning curve thing)

Nice one HarzeM, respect.
------------------------------------------------
Edit - Mods added without any problems:
SMF Shoutbox
User Email Sytem
SMF Staff Page
Love, Peace and...

cadman56


Jon Just Jon

Quote from: cadman56 on August 17, 2007, 03:19:42 PM
Do you know if this works for smf 1.3 ?

I am still running 1.1RC, so I cannot say if it will work in 1.3

If you follow my back up rules noted above, you can try it out and quickly restore the original file if it doesn't work.

Let us know how you get on.
Love, Peace and...

ianus

Greetings

Late to the party.
I search for a solution since 1.0.3 and run into a lot of unanswered requests.
So, thank you for this thread and this solution.

This is written to answer Do you know if this works for smf 1.3 ?
At least i can confirm that the changes works with 1.2
The "guest – view" isn´t affected but a registered user should see everything collapsed until he makes his own settings an unclose a category. After that the user settings will shown up next time he visited the board an he will see the categories as he left them.

Really nice. Thanks again. 

lewism

It works for me with 1.4 - thanks for the fix!  Makes our main page look a lot cleaner. 

Also answers the other question I was searching for which was why the categories were collapsible in Firefox but not in IE7.  (Answer: I was logged into Firefox...duh!)  I was  all ready to blame Microsoft again. :)

argimiro


Advertisement: