Posted by Anders Vindberg
in Lunarmedia Blog
on the 08 May. 2009
When using the ConditionalContent control from CommunityServer, always remember to use the <ContentConditions> tag when detailing the condition. Hmm that sounds obvious. No, its not. The control also has the DisplayCondition tag which is what we commonly use for other controls! Here is an example of correct usage:
<CSControl:ConditionalContent runat="server">
<ContentConditions><CSControl:QueryStringPropertyValueComparison
QueryStringProperty="condition" Operator="EqualTo"
ComparisonValue="true" runat="server" /></ContentConditions>
<TrueContentTemplate>It's true!</TrueContentTemplate>
<FalseContentTemplate>It's false!</FalseContentTemplate>
</CSControl:ConditionalContent>
Ahh that was good.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 03 Mar. 2009
I always forget this particular code and spend time finding it again and again: This is for redirecting call to the root domain in Community Server to the /forums/ folder. I usually create a blank aspx page that does the redirect - otherwise the page will load (which may be several 20-30 kb before directing). In SiteUrls_override.config you can set the "home" location name to the redirect file.
<%@ Page %>
<%@ Import Namespace="System.Web" %>
<script language="C#" runat="server">
protected override void OnInit(EventArgs e)
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
context.Response.Status = "301 Moved Permanently";
context.Response.AddHeader("Location", "/forums/");
}
</script>
Posted by Anders Vindberg
in Lunarmedia Blog
on the 27 Feb. 2009
Im currently looking for an OpenSocial API for the dotnet (.net) platform preferably written in csharp (C#). There are already APIs for PHP, Ruby, and other open source frameworks - where is the .net version?
It seems that the OpenSocial movement is less active in the proprietary world which for our sake (im part of it) is unfortunate. I believe the advent of OpenSocial will heavily be reflected in the future of the web.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Feb. 2009
In CS 2008.5 its possible to post a forum topic that is a "Question" or a "Discussion". In order to enable this you need to check two places in the Controlpanel.
- In Forum Administration - Configuration - Global Forum Settings
- Set "Enable Thread Status Tracking" to Yes
- In Forums and Groups - Forums
- Select to "Edit" the particular forum - in "Allowed Thread Types" check "Questions and Answers".
And you are done!
Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Feb. 2009
Often I find situations where I need to do a customized condition comparision. To enable this, Telligent have added the following chameleon control:
<CSControl:CustomCondition runat="server" CustomResult='<%# ((CommunityServer.Discussions.Components.Forum) ForumControlUtility.Instance().GetCurrentForum(Container)).SectionID == ForumControlUtility.Instance().GetCurrentThread(this.Page).SectionID %>'
/>
In this example I check the sectionId of the current forum (eg. in a dropdown list populated with all the forums) and the forum in which the thread im viewing is in.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 29 Jan. 2009
Today I implemented some of the best practice guidelines for speeding up websites. It has resulted in significant improved load times on the subtitle website Subscene. Although all "rules" as specified by Yahoo has not been implemented yet it has already decreased load times to the half. For future developments all guidelines will be followed, first implemented in the new translator markedplace Lingbay.
Scott Hanselman has a post about enabling proxy caching in IIS.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 21 Jan. 2009
The new marketplace for linguistic jobs (Lingbay) is nearing completion. Expected launch is around April this year. If you want to be notified when we go live sign-up today!
About Lingbay:
Lingbay is an auction-house for linguistic related jobs, including translations, proofreadings, and transcriptions.
As a freelance translator you bid on linguistic jobs and are paid the agreed amount after completion.
As an outsourcer or employer you receive competitive quotes on jobs directly from the translator.
For a successful launch the procedure is as follows:
- Collect a email-list of interested parties (active)
- Gather a registered list of translators, linguistic professionals, and students
- Launch a working beta version with active linguistic jobs
In addition to the listed procedure, a large ad-campaign will run as Lingbay is launched. A website like Lingbay
requires a critical mass the be meet in order for the marketplace to
function. First, a group of freelance translators needs to be ready to
complete linguistic jobs within a certain period. Secondly, a continous
flow of new jobs are needed to keep the marketplace active. The
strategy employed is designed to fulfill that purpose.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Jan. 2009
In Community Server its easy to add extended properties to the user profile without having to write any code:
To your CommunityServer.config file, add
<ExtendedUserData>
<add name="EXTENDED ATTRIBUTE NAME" />
</ExtendedUserData>
Then on your theme pages:
- User Register (/themes/YOURTHEME/user/createuser.aspx)
- Edit Profile (/themes/YOURTHEME/user/edituser.aspx)
- Edit User page in Membership Administration in Control Panel (/ControlPanel/Membership/UserEdit.aspx)
add the following input field:
<asp:TextBox id="EXTENDED ATTRIBUTE NAME" runat="server" />
That's it!
Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Jan. 2009
In Community Server, dynamic user fields are saved in extended properties. In order to retrieve them in Sql add the following function:
/*------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
------------------------------------------------------------------------------*/
CREATE function [dbo].[FetchExtendendAttributeValue] (
@Key nvarchar(4000),
@Keys nvarchar(4000),
@Values nvarchar(4000)
)
/*
CS uses ExtendedAttributes to allow metadata about a post, user, or section to be stored
in a special ':' delimited format. This enables storing metadata without adding new columns
to any tables, changing sprocs, etc.
However, any data stored in this format is not easily queryable (so use it wisely :)
Occassionaly, you may want to query against this data. This function should make that task simple!
Keys are stored in this format: string:S:Int:Int = Key + :S : Starting Location : Length :
An example: 'Theme:S:0:7:dummyTotalPosts:S:7:1:BannedUntil:S:8:21:UserBanReason:S:29:5:'
Values are stored in a single string with no spaces between them.
An example: 'default04/20/2005 12:16:41 AMOther'
Theme starts a 0 and continues for 7 characters (default)
dummyTotalPosts starts at 7 and coninutes for 1 character (0)
BannedUntil starts at 8 and continues for 21 characters (4/20/2005 12:16:41 AM)
*/
RETURNS nvarchar(4000)
AS
BEGIN
DECLARE @Value nvarchar(4000)
Declare @CharIndex int
Declare @StartIndex int
Declare @Len int
--Find the index of the key
Set @CharIndex = CHARINDEX(@Key + ':s',@Keys)
--If the key does not exist, return NULL
if(@CharIndex = 0)
RETURN NULL
--If the key is not the first, remove any leading keys
if(@CharIndex > 1)
Begin
Set @Keys = Stuff(@Keys,1,@CharIndex-1,'')
End
--Remove the Key from the keys list. This will
Set @Keys = Stuff(@Keys,1,Len(@Key+':S:'),'')
--Find the location of the : after the starting location
Set @CharIndex = CHARINDEX(':',@Keys)
--Grab the starting location
Set @StartIndex = SUBSTRING(@Keys,1,@CharIndex-1)
--Remove the starting location from the Keys
Set @Keys = Stuff(@Keys,1,@CharIndex,'')
--Find the lenght value's index
Set @CharIndex = CHARINDEX(':',@Keys)
--Find the lenghth value
Set @Len = SUBSTRING(@Keys,1,@CharIndex-1)
--Get the value from the values string
Set @Value = SUBSTRING(@Values,@StartIndex+1,@Len)
RETURN @Value
END
Source: http://code.communityserver.org...
Posted by Anders Vindberg
in Lunarmedia Blog
on the 16 Jan. 2009
Today I was reminded of a wonderful CSControl that will allow a textbox to initiate a submit button (when pressing enter). Using the:
<CSControl:DefaultButtonTextBox ID="..." ButtonId="SubscriptionEmailButton" runat="server" />
you define the buttonId of the submit button.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 12 Nov. 2008
Removing all SVN files from a specific folder can easily be done from within Explore. Simply run this registry file: Remove All SVN Files. It will enable a new option "Delete SVN Folders" when you right-click on a folder in Explorer.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 04 Oct. 2008
Here are some valuable information about integrating with Paypal found in the support forum (thanks to PayPal_HarryX):
There are several ways PayPal returns payment data to you after
the payment is completed. You get to choose how you get the data back.
But you have to use the correct technology for your choice. I see some
confusion about the ways you receive and process data from PayPal.
Often times the technology is mismatched with the settings you made and
you get unexpected results. I hope this article will help clear things
up.
Option 1: POST to Return Page
How does it work?
- After finishing the payment on PayPal, the customer clicks on a button.
- PayPal posts payment data to your URL in a HTML form.
- You post a form (format is described in the IPN section below) to
PayPal. PayPal responds with a single word VERIFIED or INVALID.
- If you receive VERIFIED, you can be confident that the form you
received came from PayPal and wasn't tampered with. Do whatever you
need to do with the form data.
Settings:
- specify a return url in the return variable in your html form. The return url must be an absolute url.Code:
<input type="hidden" name="return" value="your_url_here">
- set the rm variable to 2. Code:
<input type="hidden" name="rm" value="2">
- Auto Return = Disabled in account profile (if Auto Return = Enabled, you won't get any data)
- PDT = Disabled in account profile
- IPN = Disabled in account profile
I don't recommend this as a
stand-alone solution because you can't guarantee that the customer will
click on that button. Many customers simply close their browser or
navigate away because they are done with their payment.
Option 2: Payment Data Transfer (PDT)
How does it work?
- After finishing the payment on PayPal, the customer is automatically redirected to your page.
- PayPal sends a GET request to your page. If your URL contains a query string, PayPal will append parameters to the URL. For example: Code:
http://yoursite/yourpage?yourparam=yourvalue&tx=3KK900354R868601V&......
- You post a form to PayPal with cmd=_notify-synch, the tx token you received in the query string and the identity token in your account profile when you turned on PDT.Code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="cmd" value="_notify-synch">
<input type="hidden" name="tx" value="3KK900354R868601V">
<input type="hidden" name="at" value="lpeb7DhJWXz5BU43tiarWlo42x5g-Nvv0oJCORuEVsmY9JiRuVUDW2jAHUI">
</form>
- PayPal responds with a block of text with SUCCESS or FAIL on the top. If it's SUCCESS, name value pairs on separate lines follow the SUCCESS line.
- If the response has SUCCESS on the top, you read the rest of the lines from the response.
Settings:
- specify an url for PDT in your account profile or in the return variable in your html form. The url must be an absolute url.Code:
<input type="hidden" name="return" value="your_pdt_url_here">
- Auto Return = Enabled in account profile
- PDT = Enabled in account profile
- IPN = Disabled in account profile
Sample script: http://paypaltech.com/PDTGen/
More info: https://www.paypal.com/IntegrationCenter/ic_pdt.html
This approach is better than Option 1 but there still may be breakage
from the auto redirect after the payment is done. For example the
customer could close the browser or navigate away before redirect is
completed. If the redirect breaks, you won't know about the payment. It
is possible for the customer to refresh the page. So if you are
inserting records to a database, you must check for duplicates. Don't
count on the PDT url being called only once. Use PDT if you must know immediately
whether the payment went through, while the customer is still on your
site, for example for providing immediate access to digital downloads.
If you are shipping physical goods, you can wait for the IPN (see
Option 3 below). Because PDT is a front end technology, you will only
get data for the initial payment. You won't get data on eCheck
clearance and other events. If you want to get notified
programmatically about those events, you will still have to do IPN.
Option 3: Instant Payment Notification (IPN)
How does it work?
- After finishing the payment on PayPal, the customer is auto-redirected to your page ("return" variable)
- Customer returns to your page. PayPal does NOT send any payment data there.
- Separately in the background, you receive a form POST from PayPal at a different URL (notify_url variable).
- You post back a form with cmd=_notify-validate and all fields you received from PayPal. PayPal responds with a single word VERIFIED or INVALID
- If you receive VERIFIED, you can be confident that the form you
received came from PayPal and wasn't tampered with. Do whatever you
need to do with the form fields.
Settings:
- Specify an auto return url in your profile or in the return
variable in your html form. The url must be an absolute url. This is
just a generic page with no PayPal processing logic. Display something
like "Thank you and your order will be processed shortly." Code:
<input type="hidden" name="return" value="your_return_url_here">
- Specify an IPN url in your profile or in the notify_url
variable in your html form. This is where you process payment data from
PayPal. The IPN url must be an absolute url. It must also allow
anonymous access from outside of your network. If you must open your
firewall to a specific host, please note the Sandbox sends IPNs from
ipn.sandbox.paypal.com. PayPal live site sends IPNs from
notify.paypal.com. Code:
<input type="hidden" name="notify_url" value="your_ipn_url_here">
- Auto Return = Enabled in account profile
- PDT = Disabled in account profile
- IPN = Enabled in account profile
Sample script: http://paypaltech.com/SG2/
Test your IPN listener: http://paypaltech.com/Stephen/test/ipntest3.htm
More info: https://www.paypal.com/IntegrationCenter/ic_ipn.html
I recommend this approach over the 2 options
above because there is less chance for breakage. It's independent of
the customer's action. If the customer closes the browser or navigates
away, you will still receive notifications from PayPal at your
notify_url. IPN also has built-in retry mechanism. If there's a problem
reaching your notify_url, PayPal will re-try for several days. With
either of the 2 options above, you only have one shot at getting the
payment data.
Option 4: PDT + IPN
This is a belt and suspenders strategy. You use PDT to get most of
your data but use IPN as a backup to catch the redirect breakage and
for receiving other event notifications. For each IPN you receive, you
will first check to see if you already got it from PDT.
Settings:
- Specify a return url in your account profile or in the return variable in your html form. The script there processes the GET request from PayPal as described under PDT above.Code:
<input type="hidden" name="return" value="your_pdt_url_here">
- Also specify an IPN url in your profile or in the notify_url
variable in your html form. This script processes the POST data from
PayPal as descirbed under IPN above. Note the data you received may
have already been processed by PDT. Code:
<input type="hidden" name="notify_url" value="your_ipn_url_here">
- Auto Return = Enabled in account profile
- PDT = Enabled in account profile
- IPN = Enabled in account profile
I also recommend this approach if you are able to deal with the duplicates coming from different channels. You get the best of both worlds.
Where are the Profile settings for all these?
- Auto Return and default return URL are in Profile -> Website Payment Preferences
- PDT and your Identity Token (at variable) are in Profile -> Website Payment Preferences
- IPN and the default notify_url are in Profile -> Instant Payment Notification Preferences
I welcome your questions, comments and corrections however please do
not post questions or problems specific to your scripts. You should be
able to resolve most of the problems by double checking what you have
against the approaches outlined above. If not, please create a separate
thread for your specific problem. Thank you.
Message Edited by PayPal_HarryX on 08-12-2006 08:05 PM
Posted by Anders Vindberg
in Lunarmedia Blog
on the 30 Sep. 2008
Scenario: Two websites (a main and a subdomain) are running on the same IIS but different app pools. CommunityServer is on a subdomain, eg. forum.lunarmedia.com, and is used as the primary membership provider. On the main site eg. lunarmedia.com, we want to show the logged in username etc. In order to do this we need to be sure the following are present in both web.config files.
1. In web.config add (Goto here to generate a machine key):
<system.web>
<machineKey validationKey="Your_Generated_Validation_Key_Goes_Here"
decryptionKey="Your_Generated_Decryption_Key_Goes_Here"
validation="SHA1" />
<!-- Other system.web elements -->
</system.web>
2. In web.config add a domain attribute to your <authentication mode="Forms"> node:
<authentication mode="Forms">
<forms name=".CommunityServer" domain=".lunarmedia.com" protection="All" timeout="60000" loginUrl="login.aspx" slidingExpiration="true"/>
</authentication>
3. Copy the Telligent.CommunityServer.SecurityModules.dll file to both "bin" folders of the two websites. You can get the dll from the Single Sign-on download at: get.communityserver.com
At lunarmedia.com we simply link to forum.lunarmedia.com/login.aspx, logout.aspx, etc. to take advantage of Community Server's membership flow.
P.S. the domain (lunarmedia.com) is only used as an example.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 24 Aug. 2008
When updating Community Server to the 2008 version several issues may arise. Using the accompanied Updater that Telligent has supplied helps a lot, but there are still idiosyncrasies to be aware of:
- Is your email not work? Giving an error: "Iterator Failed. Type CommunityServer.MailRoom.Components.EmailJob.
Method SendQueuedEmailJob Reason Object reference not set to an
instance of an object.. etc.". The Solution: Try and delete all waiting emails in the queue. Do a "DELETE FROM mg_EmailQueue" on the database. It seems that some "old" awaiting emails from the 2007 version was causing CS2008 email client to fail.
- The default blog theme may have reverted to CS's standard theme. Goto /controlpanel/BlogAdmin/Options/SkinOptions.aspx and change the default theme to your likings.
- Check that all custom controls are working with the new update. Some of the places that could reference a control are: the App_Browsers folder, Web.Config HttpHandlers and controls section, and CommunityServer.Config Tasks section.
- From earlier blog post about the subject: Upgrading CS2007 to CS2008 - DynamicStyle.aspx in IE6
- From earlier blog post about the subject: Upgrading CS2007 to CS2008 - Timeout expired
Good luck upgrading :)
Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Aug. 2008
When upgrading a website it is usual to setup a test site of the new version. In doing so, it is important to get all IIS settings moved aswell. When Http Compression (IIS6.0) is enabled at a website running Community Server it is crucial that you disable compression on the DynamicStyle.aspx file located in your Themes/[your theme]/style/ folder. An error in IE6 will make your website display wrongly when you click using the main navigation menu. It will only display correctly (and load the DynamicStyle.aspx file) when you do a hard ctrl+F5 refresh.
To disable HTTP compression on a single file, i've made the following simple batch file: IIS6 HTTP compression on single file.zip Remember to edit the file and change the "[Identifier number]" part to your website identifier number (can be found in IIS Manager when listing all sites).
For general information about IIS6 Compression check my earlier post: IIS6 Http Compression in four easy steps