Issue displaying summary view of a custom content part in orchard - orchardcms

I have seen the following post which looks similar to mine.
Issue displaying the summary view of a custom content part in Orchard CMS using Placement.info
But when I compared my code with the solution I could not find anything different.
This is what I want to achieve:
I have two custom Content Parts built QuestionRecord and ExpertRecord. The relation between these two parts are Experts answer to Questions posted by site users.
I have a global search module which is supposed to display a combined summary result of Questions and Expert Answers. But Expert part is somehow not picking up the Summary view, it is always showing the detail view.
Placement.info:
<Match ContentType="ExpertRecord">
<Match DisplayType="Detail">
... ...
</Match>
<Match DisplayType="Summary">
<Place Parts_Expert_Summary="Content:2" />
<Place Parts_Expert="-" />
</Match>
</Match>
Driver Result methods in ExpertDriver:
protected override DriverResult Display(Expert part, string displayType, dynamic shapeHelper)
{
List<dynamic> questions = new List<dynamic>();
string partName = "Parts_Expert";
switch (displayType)
{
case "Detail":
// only load questions when showing detail record.
questions = _questionService.GetQuestionsByExpert(part.ContentItem);
break;
case "Summary":
partName += "_Summary";
break;
}
return ContentShape(partName,
() => shapeHelper.Parts_Expert(ContentItem: part.ContentItem, Questions: questions));
}
Views:
#Model dynamic
<p>This is my Expert_Summary.cshtml file</p>
I want this View to be called on from the DriverResult method, but it is calling the detail view Experts.cshtml. Both views are placed in Parts folder.
I must be missing something but could not figure out what exactly it is.
I am still fairly new to Orchard so any suggestion would be a great help for me.
Regards

Have your driver return a Combined shape with both the regular and the summary shape, and let placement sort it out. There are lots of examples throughout the code, that should be easy to find if you search for ".Combined".

Related

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

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>

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>

Orchard Placement file not hiding the Title Part

In Orchard I have a placement.info file that should hide the Title part when I view an Author:
<Match ContentType="Author">
<Place Parts_Title="-" />
<Place Parts_Breadcrumbs="-" />
</Match>
Author is a custom content type I've created and the Breadcrumbs Part is a custom part.
The breadcrumbs part is hidden, but the title is still displayed. If I inspect it with Shape Tracing it is definitely Parts_Title I want to remove, but the content of my placement file doesn't seem to work.
I do not have a whole of example to go on there, but it seems to me that this part is conflicting with the Parts_Title that ships with orchard.
Try extending the modifier in your placement as well as your shapes to something like:
Parts_MyModule_Title
This just adds some more clarity and can keep orchard from stepping all over itself.
Similar problem here.
This is because your custom part's Placement.info was loaded first and Orchard Title part was loaded after that overriding it.
To solve it, in your custom part's Module.txt, put a dependence on Title. This will force Orchard Title to be loaded first before your custom part.

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