GetPostingsByCustomProperty ??
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > GetPostingsByCustomProperty ??




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    GetPostingsByCustomProperty ??  
Ninerfan


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 12:27 PM

Hi,

I'm just trying to test how this method works and I can't seem to get any
results even though I know I have multiple postings with a custom property
named "FAQ Category" and I'm using this below test code to try and find them
and put them in a posting collection:

// Set a test variable for category name.
string TestCategory = "FAQ Category";

// 1. Get current CMS context.
CmsHttpContext cmsContext = CmsHttpContext.Current;

// 2. Find all postings with FAQ Category custom property.
PostingCollection faqPostings =
cmsContext.Searches. GetPostingsByCustomProperty(TestCategory
) as
PostingCollection;

When I run this in debug and watch the count on the posting collection named
"faqPostings" it's always at zero.

What am I doing wrong?

Thanks.





[ Post a follow-up to this message ]



    RE: GetPostingsByCustomProperty ??  
Irfan Yar


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 12:27 PM

Hi Ninerfan,
please take a look at the following things, this might help you out

1- This method returns a collection of Posting objects that contain a
CustomProperty object for which Name matches propertyName. If no matches are
found, the method returns an empty collection. This search only returns
objects that the User has rights to view and that are visible in the current
Mode.

2- If the current Mode is Published or Staging and the SessionSettings is
true, Posting objects with the property IsHiddenModePublished equal to true
are automatically removed from the collection returned by this method. In
other modes, the Posting objects are not removed.

3- If CmsContext is being used to view a historical Posting or Channel, this
method returns an empty collection.

4- The propertyName parameter must always be specified and must contain at
least one character.

5- The string matching in this search depends on the
case-sensitive/case-insensitive setting of the database. If queries of the
database default to case-sensitive comparisons, the search is case-sensitive
.
If database queries default to case-insensitive comparisons, the search is
case-insensitive.

--
Best regards,
Irfan!


"Ninerfan" wrote:

> Hi,
>
> I'm just trying to test how this method works and I can't seem to get any
> results even though I know I have multiple postings with a custom property
> named "FAQ Category" and I'm using this below test code to try and find th
em
> and put them in a posting collection:
>
> // Set a test variable for category name.
> 	string TestCategory = "FAQ Category";
>
> // 1. Get current CMS context.
> 	CmsHttpContext cmsContext = CmsHttpContext.Current;
>
> // 2. Find all postings with FAQ Category custom property.
> 			PostingCollection faqPostings =
> 	cmsContext.Searches. GetPostingsByCustomProperty(TestCategory
) as
> PostingCollection;
>
> When I run this in debug and watch the count on the posting collection nam
ed
> "faqPostings" it's always at zero.
>
> What am I doing wrong?
>
> Thanks.





[ Post a follow-up to this message ]



    RE: GetPostingsByCustomProperty ??  
Ninerfan


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 12:27 PM

Thanks Irfan, yes I've read that definition many times. However it does not
seem to be accurate. I can find plenty of examples where I can find all
postings by matching a "VALUE" of a custom property. I can't find any case o
f
how to find all postings that match a custom property name. This is really
frustrating. For example in my test case I have many test postings published
with a custom property of "FAQ Category" and then some of the postings have 
a
value of "Benefits".  I can find all of those with the value of Benefits by
using this code where I type Benefits into TextBox1.

PostingCollection cmsPostingsFound =
cmsContext.Searches.GetPostingsByCustomProperty(
"FAQ Category", TextBox1.Text.ToString())
as PostingCollection;

However I expect this code to result in all the postings that have ANY value
set for a custom property named "FAQ Category". In this case I type the
string "FAQ Category" into the text box. But it finds no postings this way.

PostingCollection cmsPostingsFound =
cmsContext.Searches.GetPostingsByCustomProperty(
TextBox1.Text.ToString())
as PostingCollection;

Man this is demoralizing. Seems like such a simple method to use but for
some reason it only works if I specify the value of the custom property. I
want to just specify the Name of the custom property and get all postings
that have "ANY" value set for that custom property.

Can you point me to any code examples of how to do that?

Thanks.


"Irfan Yar" wrote:
[vbcol=seagreen]
> Hi Ninerfan,
> please take a look at the following things, this might help you out
>
> 1- This method returns a collection of Posting objects that contain a
> CustomProperty object for which Name matches propertyName. If no matches a
re
> found, the method returns an empty collection. This search only returns
> objects that the User has rights to view and that are visible in the curre
nt
> Mode.
>
> 2- If the current Mode is Published or Staging and the SessionSettings is
> true, Posting objects with the property IsHiddenModePublished equal to tru
e
> are automatically removed from the collection returned by this method. In
> other modes, the Posting objects are not removed.
>
> 3- If CmsContext is being used to view a historical Posting or Channel, th
is
> method returns an empty collection.
>
> 4- The propertyName parameter must always be specified and must contain at
> least one character.
>
> 5- The string matching in this search depends on the
> case-sensitive/case-insensitive setting of the database. If queries of the
> database default to case-sensitive comparisons, the search is case-sensiti
ve.
> If database queries default to case-insensitive comparisons, the search is
> case-insensitive.
>
> --
> Best regards,
> Irfan!
>
>
> "Ninerfan" wrote:
> 





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:29 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register