|
Home > Archive > Content Selection Framework > February 2004 > Expression Target
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| newsgroup user 2004-02-19, 12:34 am |
| Hi,
I am using Commerce Server 2002 and I development
on "Retail2002".
I have created a targeting
expression referencing culture property, and I am using
this expression
in a target group, and this target group in an ad campaign.
How do I make the
"Commerce.ContentSelector" object
aware of this value before I invoke its GetContent method?
Can someone please, give me an actual code sample in
classic ASP .Net demonstrating how to do this.
I have been through the newsgroups with a fine tooth comb,
and I have
yet to find a concrete example.
Thanks in advance!
--
Marcelo
Following is an example of the code I am using to retrieve
the
content:
Public Function DameAnunciosBannerIzquierda() As String
Dim ctx As CommerceContext =
CommerceContext.Current
Dim userProfile As Profile = Nothing
Dim isLoggedOn As Boolean =
ctx.AuthenticationInfo.IsAuthenticated
If isLoggedOn = True Then
Dim profContext As ProfileContext =
ctx.ProfileSystem
Dim userId As String =
ctx.AuthenticationInfo.AuthTicket.UserID
userProfile = profContext.GetProfile
(userId, "UserObject")
End If
Dim csoDiscount As ContentSelector =
ctx.TargetingSystem.SelectionContexts
("Advertising").GetSelector()
csoDiscount.TraceMode = True
csoDiscount.ItemsRequested = 1
If Not IsNothing(userProfile) Then
csoDiscount.Profiles.Add("User", userProfile)
End If
csoDiscount.Size = "BannerIzq"
csoDiscount("border") = 0
Dim discountPayLoad As StringCollection =
csoDiscount.GetContent
Dim s As String
Dim sreturn As String
For Each s In discountPayLoad
sreturn = sreturn & s & "<br>"
Next
Return sreturn
End Function
| |
| Andy Xu[MSFT] 2004-02-27, 3:36 pm |
| Hello, Marcelo,
the Content Selection Framework evaluates expressions and decides to show which ads on the fly. So you don't really have to tell CSF to use this or that value. However, for performance reason, we do cache the
advertisement data. This means you need to force the advertisment runtime cache to refresh. Use bizdesk, "campaign" module, "publish campaigns" function.
for classic asp sample code of using ContentSelector, download the solution "retail" site and look for the banner.inc file under template folder. Here is the key part of the code:
Set oCSO = Server.CreateObject("Commerce.ContentSelector")
oCSO.Size = "Banner"
oCSO.Border = 1
oCSO.TargetFrame = "_top"
oCSO.NumRequested = 2
Set oUserProfile = GetCurrentUserProfile()
If Not oUserProfile Is Nothing Then
Set oCSO.UserProfile = oUserProfile
End If
Set Ads = oCSO.GetContent( Application("CSFAdvertisingContext") )
For Each Ad In Ads
Response.Write(Ad)
Next
HTH,
-- Andy
--------------------
Content-Class: urn:content-classes:message
From: =?iso-8859-1?Q?Marcelo_S=E1nchez?= <m.sanchez@europapc.com>
Sender: =?iso-8859-1?Q?Marcelo_S=E1nchez?= <m.sanchez@europapc.com>
Subject: Expression Target
Date: Thu, 19 Feb 2004 05:24:44 -0800
Lines: 68
Message-ID: <132df01c3f6eb$bd3f5e20$a501280a@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcP2670/ZCPkIqSWR7igHNBI8noRGQ==
Newsgroups: microsoft.public.commerceserver.campaigns_csf
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.commerceserver.campaigns_csf:2511
NNTP-Posting-Host: tk2msftngxa13.phx.gbl 10.40.1.165
X-Tomcat-NG: microsoft.public.commerceserver.campaigns_csf
Hi,
I am using Commerce Server 2002 and I development
on "Retail2002".
I have created a targeting
expression referencing culture property, and I am using
this expression
in a target group, and this target group in an ad campaign.
How do I make the
"Commerce.ContentSelector" object
aware of this value before I invoke its GetContent method?
Can someone please, give me an actual code sample in
classic ASP .Net demonstrating how to do this.
I have been through the newsgroups with a fine tooth comb,
and I have
yet to find a concrete example.
Thanks in advance!
--
Marcelo
Following is an example of the code I am using to retrieve
the
content:
Public Function DameAnunciosBannerIzquierda() As String
Dim ctx As CommerceContext =
CommerceContext.Current
Dim userProfile As Profile = Nothing
Dim isLoggedOn As Boolean =
ctx.AuthenticationInfo.IsAuthenticated
If isLoggedOn = True Then
Dim profContext As ProfileContext =
ctx.ProfileSystem
Dim userId As String =
ctx.AuthenticationInfo.AuthTicket.UserID
userProfile = profContext.GetProfile
(userId, "UserObject")
End If
Dim csoDiscount As ContentSelector =
ctx.TargetingSystem.SelectionContexts
("Advertising").GetSelector()
csoDiscount.TraceMode = True
csoDiscount.ItemsRequested = 1
If Not IsNothing(userProfile) Then
csoDiscount.Profiles.Add("User", userProfile)
End If
csoDiscount.Size = "BannerIzq"
csoDiscount("border") = 0
Dim discountPayLoad As StringCollection =
csoDiscount.GetContent
Dim s As String
Dim sreturn As String
For Each s In discountPayLoad
sreturn = sreturn & s & "<br>"
Next
Return sreturn
End Function
--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
|
|
|
|
|