Disable “image content” content type in CSWP
-
03-10-2020 - |
Pergunta
i'm on SP2013 Enterprise Edition and have a little problem to solve.
What i want to achieve
i would like to display all the new items through all my site collection except the images. So, for example, if a user creates an article, a page, upload/create a document or add a list item with a custom content type, i would like it to appear in my CSWP. But, if th user add an image, i don't want it to be displayed in my CSWP.
Simple, right? That is what i thought...
What I did
... Until i set my CSWP : here is the query i used (generated by the CSWP manager) :
path:"http://mySiteCollection" (IsDocument:"True" OR contentclass:"STS_ListItem")
So, as you can see, there is no restriction and that is totally normal. it gives me every new item created in my site collection, and when I have an image uploaded in a Publishing Images Library, the path generated is the one to the properties displayForm .
What i tried
In the Advanced mode of the cswp manager, i tried to add a property filter : column ContentType is different of "Image Content", which gives me the following query :
path:"http://mySiteCollection" (IsDocument:"True" OR contentclass:"STS_ListItem") ContentType<>0x0101009148F5A04DDD49CBA7127AADA5FB792B00AADE34325A8B49CDA8BB4DB53328F214*
And... it does not work. My images are still displayed and the path is still the one to the properties Form.
i tried with the "Image" Content type and had no more success with it... Maybe i'm doing it wrong, but i don't know what to do more.
Do you have any idea on how i could drum out the Images of the search result, please ?
thanks a lot, have a nice day !
Solução
Query:
path:"http://mySiteCollection"
(contentclass:STS_ListItem OR IsDocument:True)
-ContentType=Picture
-ContentType=Image
This query will return all items in http://mySiteCollection
without Picture and Image Content Type.
-ContentType=Image => Content Type not equal to Image
OR
Not contains Image and Picture Content Type ID
Query:
path:"http://mySiteCollection"
(contentclass:STS_ListItem OR IsDocument:True) -ContentTypeId:0x0101009148F5A04DDD49CBA7127AADA5FB792B00AADE34325A8B49CDA8BB4DB53328F214*
-ContentTypeId:0x010102*
Not contains Image Content Type ID query
-ContentTypeId:0x0101009148F5A04DDD49CBA7127AADA5FB792B00AADE34325A8B49CDA8BB4DB53328F214*
Not contains Picture Content Type ID query
-ContentTypeId:0x010102*
This query will return all items in http://mySiteCollection
without Picture and Image Content Type ID.
Outras dicas
I had a similar problem while working with CSWP. I needed to include a particular content type id, so I used "=" operator. But to my surprise nothing came through in results.
Then I tried "contains" operator, which worked perfect for me.
Note: Your query has "ContentType" property but value looks to be of ContentTypeID, may be this can be a problem
Try replacing ContentType with ContentTypeId in your existing query and see if it solves the problem. If not try using "not contains" operator as in shown below query.
path:"http://mySiteCollection" (IsDocument:"True" OR contentclass:"STS_ListItem") -ContentTypeId:0x0101009148F5A04DDD49CBA7127AADA5FB792B00AADE34325A8B49CDA8BB4DB53328F214*
I hope this helps!!