How to display file's download link in list? - orchardcms

I'm using FileField module. I have created:
A Content Part "Document list item" which contain File Field
A Content Type "File Item" which contain "Document list item" + Common + Title + Containable
A list which contain "File Item"
Also I've chaged Placement file by adding:
<Match ContentType="FileItem">
<Match DisplayType="Summary">
<Place Parts_Common_Metadata_Summary="Nowhere"/>
</Match>
</Match>
So now I see the list of titles. When I click title, on the details page there is a link to download.
But how to display download link in Summary?

So problem is solved:
I've added Fields_Contrib_File to the Placement file:
<Match ContentType="FileItem">
<Match DisplayType="Summary">
<Place Parts_Common_Metadata_Summary="Nowhere" Fields_Contrib_File="Content" Parts_Title_Summary="Nowhere"/>
</Match>
</Match>
I've removed display name from the template file ~/Modules/Contrib.FileField/Views/Fields/Contrib.File.cshtml:
#using Orchard.Utility.Extensions;
#if (!string.IsNullOrWhiteSpace(Model.ContentField.Path))
{
<p class="file-field">
#Model.ContentField.Text
</p>
}

Related

Related blog post in Orchard CMS?

I use Orchard CMS. I have added a content picker field in my blog post to show the related blog post. Now I want to show this related blog post in another div out of content div. How can I do this?
Looking at the Placement.info of the content picker, default the content picker items are displayed in the Content area of the content item (= your current blog post).
To move the related blog posts to for example the right sidebar, just add this to your Placement.info in your module/theme:
<Match ContentType="BlogPost">
<Match DisplayType="Detail">
<!-- AsideSecond is a global zone in your theme's layout -->
<Place Fields_ContentPicker="/AsideSecond:1"/>
</Match>
</Match>
Note the preceding forward slash, which targets a global layout zone instead of a local zone like 'Content' of the content item itself.
If you want to move the related blogposts to a self defined div in your content item, you can follow these steps:
1 - Create an alternate for the BlogPost content type (tip: use the shape tracer)
2 - Add a div somewhere in that alternate (probably named something like Content-BlogPost.Detail.cshtml), and in that a local zone:
<div class="related-posts">
#Display(Model.RelatedPosts)
</div>
3 - Alter the placement.info so that the related blogposts will display in the RelatedPosts zone:
<Match ContentType="BlogPost">
<Match DisplayType="Detail">
<!-- RelatedPosts targets the Model.RelatedPosts -->
<Place Fields_ContentPicker="RelatedPosts:1"/>
</Match>
</Match>

How to add image to blog in summary of orchard cms

I want to add image to the summary of blogs in Orchard CMS. How do I add it to the summary?
Use Placement.info. In your theme's placement.info add something like this:
<Match ContentType="Blog">
<Match DisplayType="Summary">
<Place Fields_MediaLibraryPicker="Content:1" />
<!-- Or: <Place Fields_MediaLibraryPicker_Summary="Content:1" /> -->
</Match>
</Match>
See this source code to see which shapes are available for this.
Note: I am assuming here that you are using the media library picker field to attach an image to your blog. If you use something else, you should use that shape.

Orchard CMS Custom Theme - Every page displaying Title and Date Stamp

I have created a Custom Theme. Every page is displaying the Title and a date stamp at the top.
I have found posts saying comment out 'Placement.info' in the Theme route - but this has no effect.
How can I remove both of these?
You don't need to remove the parts, just hide them from display using the placement.info file. Common and Title parts are useful parts to include with a page. Particularly common part should be included with most content types as it stores information about when an item is modified, published etc.
The parts are displayed by default. To hide them you need to add to your theme's placement information to override and hide the parts' display shapes e.g. for the Page type:
<Placement>
<Match ContentType="Page">
<Match DisplayType="Detail">
<Place Parts_Common_Metadata="-"/>
<Place Parts_Title="-"/>
</Match>
<Match DisplayType="Summary">
<Place Parts_Common_Metadata_Summary="-"/>
<Place Parts_Title_Summary="-"/>
</Match>
</Match>
</Placement>
This hides the metadata and title for both detail and list views by putting them in the '-' zone. Because the '-' zone does not exist, the shapes are not displayed.
See these docs for more info on placement:
http://docs.orchardproject.net/Documentation/Understanding-placement-info
I went to Content / Content Types / Edit Page
Remove 'Title' & 'Parts Common' - seems to fix it.

How to add Image Field to Blog Post Summary in Orchard CMS?

Looking to display the Image Field in the Blog Post Summary on my Orchard site. It current displays on the blog post itself but not in the summary. How do I add it to the summary?
The display of parts and fields is defined in the placement.info files found in each module. Assuming you're using the Image Field from the Contrib.ImageField module, You will need to override the default placement of the field for the summary display type (which is defined in Modules\Contrib.ImageField\Placement.info) which by default is:
<Match DisplayType="Summary">
<Place Fields_Contrib_Image="-"/>
</Match>
You can do this by adding the following to your theme's placement.info file (note I have restricted this to the BlogPost content type only) e.g.
<Match ContentType="BlogPost">
<Match DisplayType="Summary">
<Place Fields_Contrib_Image="Content"/>
</Match>
</Match>
This displays the image in the Content zone for the summary view of BlogPost content items. For more info on placement in Orchard see http://docs.orchardproject.net/Documentation/Understanding-placement-info
You can use the Media Library Picker Field.
I did the following steps to add image field to blog summary:
add Media Library picker field to Blog-Post content Type
then in the placement.info add the following
<Match ContentType="Blog">
<Match DisplayType="Summary">
<Place Part_Image_Summary="Content">
</Match>
</Match>

Orchard CMS - Remove Title and Metadata(published date) in a post

How do I remove the Title and Metadata(published data) in a post? Can this be done in Placement.info? I tried creating a custom content but doesn't look like a best solution. I just done it with CSS but I know this could be done in another way.
You can edit the Placement.info file in your current theme's root folder to not display the title and publish date:
<Placement>
<Match DisplayType="Detail">
<Place Parts_Title="-"/>
<Place Parts_Common_Metadata="-"/>
</Match>
<Match DisplayType="Summary">
<Place Parts_Title="-"/>
<Place Parts_Common_Metadata="-"/>
</Match>
</Placement>
See this post for further details: Orchard: Anatomy of a theme
Also, in case you are wondering where names like Parts_Title come from, see Customizing Orchard using the Designer Helper Tools (specifically shape tracing).
Alternatively, if you want to keep the title meta in the head whilst removing the title on every page create a Parts.Title.cshtml file in the view folder of your theme and then put
#{
Layout.Title = Model.Title;
}
which is exactly the same as the normal code except we remove the <h1> tag
#{
Layout.Title = Model.Title;
}
<h1>#Model.Title</h1>

Resources