|
Home > Archive > Microsoft Content Management Server > April 2006 > GetPostingsByCustomProperty ??
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]
| Author |
GetPostingsByCustomProperty ??
|
|
| Ninerfan 2006-04-27, 7:27 am |
| 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.
| |
| Irfan Yar 2006-04-27, 7:27 am |
| 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 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.
| |
| Ninerfan 2006-04-27, 7:27 am |
| 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 of
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 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:
>
|
|
|
|
|