Match tag in placement.info doesn't work in my case - orchardcms-1.10

I use Orchard CMS 1.10.1. I have a content type named "Animal" and I have a content Item named "Gold fish". This content item has a MediaLibraryPicker Field.
this field has a "Parts_Common_Metadata_Summary" that shows the create date. what I need is to not display this Create Date.
In Placement.info file of my current theme I added this Code to achieve my goal
<Match ContentType="Animal">
<Place Parts_Common_Metadata_Summary="-"/>
</Match>
This doesn't work but when I put the Place tag without Match tag it works.
My question is what is wrong with my match tag? what is the problem?
ps: ContentType Animal is correct and I also used nested Match tags for Display type Detail and summery also didn't work.

That is because the MediaLibraryPickerField renders another Meta part, specific for the image.
Try this in your placement.info:
<Match ContentType="Animal">
<Place Parts_Image_Metadata="-" />
</Match>

Related

Duplicate an orchard part

I'm trying to use Placement.info instead of overwriting a complete content template and i need to have a part (Parts_Title) displayed in the Content zone and in the Header zone. I was thinking that have two place with that Part in the Placement.info file would do the trick but it seems that the last one wins.
Is there a way to do that? I'm using Orchard 1.9.1.0
Edit 2016-03-16 following Alexander's answer:
There's something i should do wrong; i have a content type designed in the dashboard (no code) named OffreEmploi. I use Content-OffreEmploi.cshtml as the alternate. Here is the code:
#using Orchard.ContentManagement.Utilities;
#Display(Model.Header);
#Display(Model.Content);
#Display(Model.LocalZoneName);
and here is my placement.info
<Match ContentType="OffreEmploi">
<Place Fields_DateTime-DateDebut="Header:2"/>
<Place Fields_Common_Text-Duree="Header:3"/>
<Place Fields_Common_Text-Localisation="Header:4"/>
<Place Fields_Boolean-Temporaire="Header:5"/>
<Place Fields_DateTime-DateExpiration="Header:6"/>
<Place Parts_Common_Metadata="-"/>
<Place Fields_Common_Text-TexteIntroduction="Content:1"/>
<Place Parts_Title="Header:1" />
<Place Parts_Common_Body="Content:3" />
<Place Parts_Title="LocalZoneName:1" />
</Match>
the part Parts_Title is rendered only at the end (in the LocalZoneName)
You can't do this by using only placement.info. The best way for displaying content part twice is to use special local zone for that content part:
Create alternate for Content. Display a zone twice in it alternate by using #Display(Model.LocalZoneName)
Use that local zone in placement.info to render your part inside it Parts_Title="LocalZoneName:1"
Placement.info allows you to specify a single place to put your part in. This is the reason behind the behavior you see - the last entry wins (LocalZoneName:1). And this is where your part's content now resides in - the LocalZoneName.
What Alexander was actually suggesting, and what's the usual solution to this (not unusual) scenario is to use a separate, unique zone to put your part in, and render that zone multiple times, ie.:
#using Orchard.ContentManagement.Utilities;
#Display(Model.LocalZoneName);
#Display(Model.Header);
#Display(Model.LocalZoneName);
#Display(Model.Content);
This will make your LocalZoneName (which now containes the Title part) to be rendered twice - before the Header and Content zones.

Orchard CMS - How to Get Current DisplayType

I have a custom ContentPart as well as an editor view under Views/EditorTemplates/Parts/ folder. I am trying to figure out the appropriate DisplayType value to use in my placement.info file to get this view to kick in. I see it show up if I use something like this:
<Match ContentType="MyType">
<Place Parts_MyPart_Edit="Content"/>
</Match>
But I'd like to be able to target it a little more explicitly like:
<Match ContentType="MyType">
<Match DisplayType="????">-->
<Place Parts_MyPart_Edit="Content"/>
</Match>
</Match>
I have tried "Detail", "Summary", and "SummaryAdmin" unsuccessfully.
So 2 questions:
Is there a standard list of "DisplayType" values documented somewhere?
Is there a way to discover what the "DisplayType" is at runtime via a breakpoint or otherwise so that I can further restrict it in the placement.info?
Edit
Thinking about this a bit more, is 'DisplayType' even involved when Editor templates are used? I just realized that Parts_MyPart_Edit may be restrictive enough since it is already targetting _Edit. Is this right, or is there also an option to match on 'DisplayType' that can be used for editor templates?
1: Don't know exactly where the correct documentation is on this topic, but this is the correct syntax:
<Match DisplayType="Summary"> Detail and SummaryAdmin are also valid display types.
Besides that, you can also define your own display type:
var shape = _contentManager.BuildDisplay(item, "CustomDisplayType");
Then your shapes/views must be named as YourShape.CustomDisplayType.cshtml.
Then you can use your displaytype in placement.info:
<Match DisplayType="CustomDisplayType">
<Place Parts_YourPart="Content:1" />
</Match>
2: Use the 'shape tracer' module. When enabled you can find in the front-end which display type is used.
You probably made a mistake with either the <Place Parts_ section or your part driver is not correctly implemented. Also check if your shape's name is correct.
Posting this as an answer, since I don't have a high enough reputation to add comment yet :)
If you are interested in using Shape Tracer on admin pages, open up the ShapeTracingFactory.cs file in Orchard.DesignerTools module, and comment out the following line in the IsActivable method:
if (AdminFilter.IsApplied(new RequestContext(_workContext.HttpContext, new RouteData())))
return false;
I have found this extremely useful for figuring out exactly what is happening during Content Authoring tasks

Modify the orchard search to display Meta Description, Link and Page Title

I need to modify the existing search module in Orchard such that it displays the Title and Meta Description in the search List.
First of all i added the meta content part to my content types and it is working as i wanted.
Now i don't know how to index Meta content part as there is no option to select the content part in Search Settings. As it is not indexed so when i search on the website Meta content part doesn't appear in shape tracing. As i want to display title, link and meta description in the the search results so i manage to display Title and the link but i don't know how to Meta description in the search result.
Just to play around i added following Meta Parts and content types but its not working
<Place Parts_Meta="Content:2"/>
<Place Parts_Meta_Description="Content:3"/>
<Place Parts_Metas="Content:4"/>
and many more but it seems to be not working.
I think as meta tags are not showing in indexing so may be because of that it is not getting displayed. I don't know exactly how to proceed with it, Please help.!
The search settings does not have Meta Parts or even i can not add it to indexing from the content part.
You don't need to modify the search module for this, just adjust the placement for your content type. The search module displays content items using the "Summary" display type. Use Shape Tracing to find all the properties you need to hide.
So, for example, if your Content Type is called Page then you want this...
<Match ContentType="Page">
<Match DisplayType="Summary">
<Place ...add placement info... />
</Match>
</Match>

Content part showing in admin

I have a custom content part, and I added it in a content item. it works fine, but there is a little problem in content items list on admin: the content part is appearing on it.
here is an image of my problem: http://imageshack.us/photo/my-images/163/2b68.png/
In the Placement.info in your module, add the following line:
<Match DisplayType="SummaryAdmin">
<Place Parts_MyPart="-"/>
</Match>

Using Orchard CMS, How do I hide items in a container content type?

I have been attempting to hide the contained items of a Page content type. I have been manipulating the placement.info file in my theme but I am not seeing the results I would expect.
Here's my bruit-force attempt:
<Match Path="/about">
<Match ContentType="Page">
<Match DisplayType="Detail">
<Place Parts_Common_ContentItems="-"/>
<Place Parts_Container_Contained="-"/>
<Place Parts_Container_Contained_Summary="-"/>
<Place Parts_Container_List="-"/>
</Match>
</Match>
</Match>
I have scoured StackOverflow for the answer and I have used the Shape Tracing module to give me direction on designing my placement.info file but I still seem to be missing something.
Any pointers are appreciated!
Thanks.
You cannot hide the content of a container using only Placement.info because the list is rendered by its own controller (Orchard.Core.Containers.Controllers.ItemController) instead of using a shape in the standard orchard shape rendering sytem.
However you may use your own (very simple) controller to build a display without this child list.
I'd say don't put it in the container if you don't want it to appear in there. You might also want to check out taxonomies, that provide a much better and flexible approach to classifying your contents.

Resources