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! )
Using CS2007, there are a couple ways to accomplish this:
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.
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
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
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: Using CS2007, there are a couple ways to accomplish this: 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.
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!
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.
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
I tried number 2 but i get the error
Parser Error Message: Unknown server tag 'CSControl:ForumPropertyValueComparision'
Did something change in 3.1
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.
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.
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
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">
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.
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.
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com