Different Themes for different forums

This post has 43 Replies | 6 Followers

Not Ranked
Posts 3
Points 60
lombardox Posted: Mon, Mar 19 2007 12:59 PM

I have two (notional) forums, ForumA and ForumB. I also have two themes, ThemeA and ThemeB. I want all users looking at ForumA to see it in ThemeA and all users viewing ForumB to see it in ThemeB.

Anyone know whether it is possible to implement this out of the box, or if it isn't what's the best way of going about it? I'm kind of surprised that there haven't been more people looking at how to do this (unless I've missed something very obvious! Embarrassed)

 

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,580
CS Developers
Ben Tiedt replied on Wed, Mar 21 2007 8:52 AM

Using CS2007, there are a couple ways to accomplish this:

  1. If your changes can be accomplished using CSS, then you can modify the forum-related theme pages (web/themes/[theme name]/forums/...) to add the custom CSS file according to the current forum (which can be retrieved from the page as CurrentForum), such as:

    <script language="C#" runat="server">
    void Page_Load()
    {
       if (CurrentForum != null && CurrentForum.SectionID == 5)
          CommunityServer.Controls.Head.AddStyle(CSControlUtility.Instance().ResolveThemeUrl("~/style/forum5.css" ), "screen", Context);
    }
    </script>

    this will add the forum5.css stylesheet in the style sub-folder off of the current theme if the current Forum has a SectionID of 5.
  2. If your changes are smaller (including some controls or excluding some controls) you can use the Chameleon condition controls to hide or show content:

    <CSControl:PlaceHolder runat="server">
       <DisplayConditions><CSForum:ForumPropertyValueComparison runat="server" ComparisionProperty="SectionID" Operator="EqualTo" ComparisonValue="5" /></DisplayConditions>
       <ContentTemplate>
         ... displayed only for forum with SectionID 5....
       </ContentTemplate>
    </CSControl:PlaceHolder>


    or

    <CSControl:PlaceHolder runat="server">
       <DisplayConditions Operator="Not"><CSForum:ForumPropertyValueComparison runat="server" ComparisionProperty="SectionID" Operator="EqualTo" ComparisonValue="5" /></DisplayConditions>
       <ContentTemplate>
         ... displayed only for forum without SectionID 5....
       </ContentTemplate>
    </CSControl:PlaceHolder>

  3. If your entire layout requires changes depending on the current forum, you can always load user controls containing the entire page's theme -- such as:

    <script language="C#" runat="server">
        void Page_Init()
        {
            if (CurrentForum != null)
            {
                if (CurrentForum.SectionID == 5)
                    ControlContainer.Controls.Add(Page.LoadControl("forum5-currentPage.ascx" ));
                else
                    ControlContainer.Controls.Add(Page.LoadControl("generic-currentPage.ascx" ));
            }
        }
    </script>

    <asp:PlaceHolder runat="server" ID="ControlContainer" />

Ben Tiedt's Blog

  • | Post Points: 80
Not Ranked
Posts 3
Points 60
lombardox replied on Thu, Mar 22 2007 7:07 AM
Thanks for that Ben. Unfortunately I'm restricted to 2.1 for the project that I'm currently working on. Can I use a similar approach? I think scenario 1 that you mention above is what I'm looking to achieve.
  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,580
CS Developers
Ben Tiedt replied on Thu, Mar 22 2007 8:19 AM

If you're using 2.1, then it's a little more difficult, but you can implement scenario 1...

You can add the following code to the top of forums pages that you want to include custom CSS files:

<script language="C#" runat="server">
protected override void OnLoad (EventArgs e)
{
  base.OnLoad(e); 

  CommunityServer.Components.CSContext csContext = CommunityServer.Components.CSContext.Current;

  int sectionID = -1;
  if (csContext.SectionID > 0)
    sectionID = csContext.SectionID;
  else if (csContext.PostID > 0)
  {
    CommunityServer.Dicussions.Components.ForumPost post = CommunityServer.Discussions.Components.Posts.GetPost(csContext.PostID, csContext.User.UserID, false, false);

    if (post != null)
       sectionID = post.SectionID;

  }


  if (sectionID == 5)
      CommunityServer.Controls.Head.AddStyle(csContext.Response.ApplyAppPathModifier("~/Themes/" + csContext.User.Theme + "/Style/forum5.css"), "screen", Context);
}
</script>

This will perform the same function as scenario 1 and should work in CS2.1.

Ben Tiedt's Blog

  • | Post Points: 5
Not Ranked
Posts 10
Points 150
fish007 replied on Wed, May 9 2007 4:39 AM

Hello,

The sectionid is that the number of the forum shown in de browser? Can i make some quick changes in a file, so that i have an example of some changings?

regards,

Steven

 

 

  • | Post Points: 5
Top 75 Contributor
Male
Posts 266
Points 1,140

Hey Ben,

I'm trying to use Method #1 on home.aspx in Themes/ThemeName/Common/, but it won't add the style. I'm using CS2007 RTM (not SP1... yet). Any ideas?

-Robert

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,580
CS Developers
Ben Tiedt replied on Tue, May 22 2007 10:36 AM

interscape:

I'm trying to use Method #1 on home.aspx in Themes/ThemeName/Common/, but it won't add the style. I'm using CS2007 RTM (not SP1... yet). Any ideas?

Could you post your code?  Method #1 was intended to be used within forum pages -- it depends on having a Forum in the page-level context.  Home.aspx shouldn't have a Forum in the page-level context which may be the reason it isn't working.

Ben Tiedt's Blog

  • | Post Points: 5
Top 150 Contributor
Posts 180
Points 2,655
srelliott replied on Mon, Sep 10 2007 6:12 PM

Ben Tiedt:

Using CS2007, there are a couple ways to accomplish this:

  1. If your changes can be accomplished using CSS, then you can modify the forum-related theme pages (web/themes/[theme name]/forums/...) to add the custom CSS file according to the current forum (which can be retrieved from the page as CurrentForum), such as:

    <script language="C#" runat="server">
    void Page_Load()
    {
       if (CurrentForum != null && CurrentForum.SectionID == 5)
          CommunityServer.Controls.Head.AddStyle(CSControlUtility.Instance().ResolveThemeUrl("~/style/forum5.css"Wink, "screen", Context);
    }
    </script>

    this will add the forum5.css stylesheet in the style sub-folder off of the current theme if the current Forum has a SectionID of 5.

I don't quite understand what you're saying here.  Will you please describe this option in a little more detail?  Also, I don't have a web/themes/[theme name]/forums/ folder.  After the /themes/default/ folder, there's just Masters, Skins, Style, Images...unless I'm looking at this all wrong.  Please help!

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,580
CS Developers
Ben Tiedt replied on Mon, Sep 10 2007 6:33 PM

srelliott:
I don't quite understand what you're saying here.  Will you please describe this option in a little more detail?  Also, I don't have a web/themes/[theme name]/forums/ folder.  After the /themes/default/ folder, there's just Masters, Skins, Style, Images...unless I'm looking at this all wrong.  Please help!

If those are the folders that you have, you're using CS2.1 or earlier.  These instructions only apply to CS2007.

Ben Tiedt's Blog

  • | Post Points: 20
Top 150 Contributor
Posts 180
Points 2,655
srelliott replied on Mon, Sep 10 2007 6:55 PM

oops.  I should have caught that.  I just started messing around with cs2007 a day or two ago and had the wrong file opened.  Thanks

  • | Post Points: 5
Not Ranked
Posts 36
Points 525
rkcarlin replied on Sun, Sep 23 2007 7:28 PM

I tried number 2 but i get the error

Parser Error Message: Unknown server tag 'CSControl:ForumPropertyValueComparision'

Did something change in 3.1

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,580
CS Developers
Ben Tiedt replied on Mon, Sep 24 2007 9:59 AM

rkcarlin:

I tried number 2 but i get the error

Parser Error Message: Unknown server tag 'CSControl:ForumPropertyValueComparision'

Did something change in 3.1

You should use <CSForum:ForumPropertyValueComparision />... <CSControl:ForumPropertyValueComparision /> doesn't exist.

Ben Tiedt's Blog

  • | Post Points: 20
Not Ranked
Posts 36
Points 525
rkcarlin replied on Mon, Sep 24 2007 10:30 AM

My error I tried CSControl after CSForum didnt work.  I put back in CSForum and got

Parser Error Message: Unknown server tag 'CSForum:ForumPropertyValueComparision'.

Here is the full error, I commented out one display condition and replaced it with the one listed in 2 above to minimize anything else being wrong.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'CSForum:ForumPropertyValueComparision'.

Source Error:

Line 22: <%--            <DisplayConditions Operator="Not"><CSControl:UserPropertyValueComparison runat="server" UseAccessingUser="true" ComparisonProperty="IsAnonymous" Operator="IsSetOrTrue" /></DisplayConditions>
Line 23: --%>	        
Line 24:                    <DisplayConditions><CSForum:ForumPropertyValueComparision runat="server" ComparisionProperty="SectionID" Operator="EqualTo" ComparisonValue="5" /></DisplayConditions>
Line 25: <ContentTemplate>
Line 26: 	            <div class="CommonSidebarArea">

Source File: /themes/default/forums/forums.Master    Line: 24

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,580
CS Developers
Ben Tiedt replied on Mon, Sep 24 2007 11:00 AM

rkcarlin:

My error I tried CSControl after CSForum didnt work.  I put back in CSForum and got

Parser Error Message: Unknown server tag 'CSForum:ForumPropertyValueComparision'.

Sorry, apparently in my example, I spelled "Comparison" incorrectly.  I've updated the original post.

Ben Tiedt's Blog

  • | Post Points: 20
Not Ranked
Posts 36
Points 525
rkcarlin replied on Mon, Sep 24 2007 11:14 AM

Thanks that worked.  It is one of those words that just doesn't pop out as being mispelled.

Also comparison(comparision) properties is also mispelled.

  • | Post Points: 20
Page 1 of 3 (44 items) 1 2 3 Next > | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com