Support Forum

Display specific group

MO Moggle
Moggle
Member

I am currently working on a theme. I have managed to display all the Groups + Forums on the left and then the topics of a forum that I have clicked into on the right.

However I want to be able to only display a specific Group + its associated forums when viewing Topics from a particular Forum.
For example:
If clicking onto forum 1 in Group A. Display Group A (and forums) on left and Topics from forum 1 on right.
http://i43.tinypic.com/30c5bbb.jpg

17 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

So that is very close to our iForum theme. have you looked at that? Limiting the group being displayed on the left would be pretty simple as long as you have a way of identifying it. The group ID will be in the data object. IS this what you want to know?

MO Moggle
Moggle
Member

Thanks for the reply. Yes I have looked at the iForum theme which is what my current theme is based on. When i enable the iForum theme to see what it does, it still displays all the groups + forums on the left and the topics of the forum i’m viewing.

I’m assuming that i’ll need to use an if statement similar to the one below, if current forum, then display the group which forum belongs to.

if($firstForum) {
global $spThisForum;
$firstForumId = $spThisForum->forum_id;
$firstForum = false;
}

I just cannot work out how to do this. Any hints would be much appreciated.

YS Yellow Swordfish
Yellow Swordfish
Member

First let me see if I fully understand the question.
Are you asking how – (using iForum as a base) – when displaying the spForumView template which in turn calls the spGroupSubView template to pop[ulate tge left hand column then you want that left hand column to only show the forums in the Group to which the selected forum belongs.
Is that about right?

YS Yellow Swordfish
Yellow Swordfish
Member

Well – I am guessing here a little as I am pousghed for time but you could try something like:

if( $spThisForum->group_id == $spThisGroup->group_id )
    # all the template functions run
}

At least I would try that first.

MO Moggle
Moggle
Member

Thank you. I’ve tried the code and nothing seems to happen. I’m not sure whether it is to do with the way i am calling the template functions.

In ForumView, i have it calling GroupSubView which displays the groups and ForumSubView which has been changed to display the topics when going into a particular forum. GroupView has been changed to display the groups/forums with number of topics/replies and last poster info as well as the recentpostslist/statistics.

I assume I should be placing the above code into ForumView. I’ll continue using the above code to get me started and will update if i get further.

YS Yellow Swordfish
Yellow Swordfish
Member

I probably need to know more about the code you are putting in place.

I would suggest you visit the Toolbox > Data Inspector. On this panel you can turn on various data items that will then display their content at the place of use. only  you will be able to see these by the way. But it is a good way of being able to inspect the properties that come with each view and see where they are used and to see what properties are available at for any given view. Might help you ascertain what you need to use…

MO Moggle
Moggle
Member

Thank you.  I have enabled Data Inspector and have noticed something.

Where my Groups are being displayed, it shows the Group of the Forum that i am viewing and below the Group, it is also showing all the Groups as well.

 

I have now gone one step further.  Somehow I have managed to display the Forum on the list and the associated Topics on the right.

 

I am using this code:

if( $spThisForum->group_id == $spThisGroup->group_id ) 

sp_SectionStart('tagClass=spGroupViewSection', 'groupHeader');

sp_GroupHeaderName('tagClass=spHeaderName');

    sp_SectionEnd('tagClass=spGroupViewSection', 'groupHeader');

            sp_SectionStart('tagClass=spGroupViewSectionBox', 'groupHeader');
            sp_SectionStart('tagClass=spGroupViewForumBox', 'groupHeader');

    if (sp_this_forum()):
          sp_SectionStart('tagClass=spGroupForumSection', 'forum');
                sp_ColumnStart('tagClass=spColumnSection spLeft&width=12%&height=55px');
                 sp_ForumIndexIcon('tagClass=spRowIcon spLeft');
                sp_ColumnEnd();

                sp_ColumnStart('tagClass=spColumnSection spLeft&width=80%&height=55px');
                 sp_ForumIndexName('tagClass=spRowName', __sp('Browse topics in %NAME%'));
                 sp_ForumIndexDescription('tagClass=spRowDescription');
                 sp_ForumIndexPageLinks('tagClass=spInRowPageLinks spLeft', __sp('Jump to page %PAGE% of topics'));
                 sp_ForumIndexSubForums('icon=0', '', __sp('Browse topics in %NAME%'));                       sp_InsertBreak();        
                sp_ColumnEnd();
                 sp_InsertBreak();
                 sp_SectionEnd('', 'forum');
                else:
                 sp_NoForumsInGroupMessage('tagClass=spMessage', __sp('There are no forums in this group'));
                endif;
                 sp_SectionEnd('', 'groupHeader');
                 sp_SectionEnd('', 'groupHeader');
    sp_SectionEnd('', 'groupView');

I have removed all unnecessary code from the above. When you have the time, could you look this over and let me know where i have gone wrong or whether I am on the right track.

YS Yellow Swordfish
Yellow Swordfish
Member

I can try and take a look later but one immediate thing I see is that when you use an if statement then you do have to enclose all the statements that qualify in braces. I see no opening brace after your intial ‘if’ and no closing brace either. This means that the if will only apply to the one line following it.

MO Moggle
Moggle
Member

I’ve added in the brackets and it hasn’t made any difference.  I’m not in any rush so take your time in looking into this.  I’m going to keep working on this to see if i’ve missed anything.

 

Thank you!

MP Mr Papa
Mr Papa
Member

well, technically you can use the : and endif, but harder to read… plus it helps if you have the indentation correct…

can you repost your corrected code?

MO Moggle
Moggle
Member

Hi Mr Papa,

I assume you mean the code that i have posted but with the correct indentations, well here goes:

<?php
# --------------------------------------------------------------------------------------
#
#    Simple:Press Template
#    Theme        :    myTheme
#    Template    :    group
#    Author        :    Simple:Press
#
#    The 'group' template is used to display the Group/Forum Index Listing
#
# --------------------------------------------------------------------------------------

# Start the Group Loop
# ----------------------------------------------------------------------
if( $spThisForum->group_id == $spThisGroup->group_id ) :

    # Start the 'groupHeader' section
    # ----------------------------------------------------------------------
    sp_SectionStart('tagClass=spGroupViewSection', 'groupHeader');
        sp_GroupHeaderName('tagClass=spHeaderName');
    sp_SectionEnd('tagClass=spGroupViewSection', 'groupHeader');

    sp_SectionStart('tagClass=spGroupViewSectionBox', 'groupHeader');
        sp_SectionStart('tagClass=spGroupViewForumBox', 'groupHeader');
            # Start the Forum Loop
            # ----------------------------------------------------------------------
            if (sp_this_forum()):

                # Start the 'forum' section
                # ----------------------------------------------------------------------
                sp_SectionStart('tagClass=spGroupForumSection', 'forum');

                # Column 1 of the forum row
                # ----------------------------------------------------------------------
                    sp_ColumnStart('tagClass=spColumnSection spLeft&width=12%&height=55px');
                        sp_ForumIndexIcon('tagClass=spRowIcon spLeft');
                    sp_ColumnEnd();

                    # Column 2 of the forum row
                    # ----------------------------------------------------------------------
                    sp_ColumnStart('tagClass=spColumnSection spLeft&width=80%&height=55px');
                        sp_ForumIndexName('tagClass=spRowName', __sp('Browse topics in %NAME%'));
                        sp_ForumIndexDescription('tagClass=spRowDescription');
                        sp_ForumIndexPageLinks('tagClass=spInRowPageLinks spLeft', __sp('Jump to page %PAGE% of topics'));
sp_ForumIndexSubForums('icon=0', '', __sp('Browse topics in %NAME%'));                        sp_InsertBreak();        
                    sp_ColumnEnd();
                            sp_InsertBreak();

                sp_SectionEnd('', 'forum');

            else:
                sp_NoForumsInGroupMessage('tagClass=spMessage', __sp('There are no forums in this group'));
            endif;

        sp_SectionEnd('', 'groupHeader');
    sp_SectionEnd('', 'groupHeader');
endif;
?>

 

This is posted in GroupSubView.php. If you need anymore info, feel free to ask. Thanks

MP Mr Papa
Mr Papa
Member

sorry, you were working with Andy and not sure what you are doing?  this is your theme?

you might to verify that $spThisForum->group_id is set up at the time you are checking it…  think it doesnt get set up until the sp_this_forum() call…

MO Moggle
Moggle
Member

Thank you for your reply.

 

Yes this is my theme.

The above code works as far as only displaying the current forum and the topics associated with the forum as shown below:

http://i43.tinypic.com/35iaw7m.jpg

For Example:

  • Viewing topics of Forum B which belongs to Group A on the right
  • Only displaying Group A and Forum B on the left
  • No Group A Header

However I want it to display the group heading and its associated forums with the topics that I am currently viewing:

For Example:

  • Viewing topics of Forum B which belongs to Group A on the right.
  • Group A and its associated forums on the left.