How to remove items from a page? - orchardcms

I have just downloaded and installed Orchard CMS and started to play with it.
Created some widgets in zones, and created a blog and customized my top menu.
Now I want to do some modifications for my welcome page.. I want to remove the title field and the line where created date is shown, only to show the body.
(This will only be for the welcome page. The other pages should not be affected)
How do I do this? What is the right approach?

I had the same desire to remove the published date. In my case I wanted to remove them from ALL pages.
One way to to do this is to adjust the Placement of Shapes...
The Shape you need to influence the placement of is the Parts_Common_Metadata shape. To make it invisible you make the placement value equal to 'Nowhere'.
So I added this to a placement.info file inside my theme folder:
<Match DisplayType="Detail">
<Place Parts_Common_Body="Content:before"
Parts_Tags_ShowTags="Content:after"
Parts_Comments="Footer"
Parts_Common_Metadata="Nowhere"/>
</Match>
<Match DisplayType="Summary">
<Place Parts_Common_Body_Summary="Content"
Parts_Comments_Count="Nowhere"
Parts_Tags_ShowTags="Nowhere"
Parts_Common_Metadata_Summary="Nowhere"
Fields_Common_Text="Nowhere"/>
</Match>
If you want this to apply only to certain content types you can wrap the above within a parent tag such as:
<Match ContentType="Blog"></Match>
I'm not sure how you would apply this only to the Welcome page though...

In case someone finds the response later and needs the mark up for removing the page title on the homepage, here it is:
<!-- Remove the page title from the homepage -->
<Match Path="~/">
<Place Parts_Title="-" />
</Match>

To edit the html itself/the views you have to edit the cshtml files. I still have to figure this out properly.
To just edit the content, in the Dashboard:
Click Widgets
Click Homepage under layers
You can now add any widget here into the homepage layer and it will only show on the homepage.
You can add html widgets to do some custom stuff.
Hope it helped.

Related

Add Thumbnail / picture on the blog list summary orchard

How do I add image / thumbnail before the blog summary using orchard cms?
Please give step by step instruction because I'm still new using this cms
i already tried this technique but still not working
Thank you
I would suggest that you enable the shape tracer module in Orchard, this will assist you in understanding exactly what is being pulled through on the customer view side of things.
Read more about it here:
http://docs.orchardproject.net/en/latest/Documentation/Customizing-Orchard-using-Designer-Helper-Tools/
Firstly when you are editing your Placement.info file, it does not always pull through immediately, I find that you have to recycle the application pool in IIS for the specific site.
Also get a better understanding of placement info here: http://docs.orchardproject.net/Documentation/Understanding-placement-info
Secondly you need to understand the order in which elements are being loaded before you change any placement of it.
I followed the following steps:
Created a blog called 'blog'
Edited the Content Type called 'Blog' and added the a field called 'image' as a 'Media Library Picker Field'
I viewed the '/blog' in the customer side and inspected it with 'shape tracer'
I found that the detail view was loading for the blog description/summary;
The 'Parts_Blogs_Blog_Description' which is the summary was loading in 'content:before' by default;
The 'Fields_MediaLibraryPicker' was loading at 'content:after'
So, in this case you will have to change both:
If you had to place both in 'content:before', then Orchard would still not know which one to put first. This is what you need to put in your placement.info file:
<Match ContentType="Blog">
<Match DisplayType="Detail">
<Place Fields_MediaLibraryPicker-image="Content:1"
Parts_Blogs_Blog_Description="Content:2" />
</Match>
</Match>
If you want to do this for Blog Posts, you will do it exactly the same. But just refer to the blog post content type. The 'Media Library Picker Field' was called 'Images'. And you have to change the 'Part_Common_Body' placement.
<Match ContentType="BlogPost">
<Place Fields_MediaLibraryPicker-Images="Content:1"
Parts_Common_Body="Content:2" />
</Match>
To remove the Title and metadata from the images selected:
<Match ContentType="Image">
<Match DisplayType="Summary">
<Place Parts_Title_Summary="-"
Parts_Common_Metadata_Summary="-"/>
</Match>
</Match>
Also make sure that you selected images for the blog and blog posts. The Placement.info file can be found in your theme folder.
This was done in Orchard 1.10.2. I do not know if this will differ in other versions.
You should use the build in MediaLibraryPickerField as described in the second answer, but in your case for the Blog instead of the BlogPost:
Attach a Media Library Picker Field to your 'Blog' content type
Edit your theme's placement.info and include something like this:
<Match ContentType="Blog">
<Match DisplayType="Summary">
<Place Part_Image_Summary="Content:before" />
</Match>
</Match>

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>

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.

Orchard Blog Summary Text

On the blog summary page -the one that lists your blog posts- I could do with having a bit more of the text visible from each blog post.
Is this possible?
I cant see it anywhere in the settings and for some reason shape tracing isnt letting me see what the template is for this.
I needed to do the same thing recently on Orchard v1.6. You're using the shape tracing so you're going in the right direction. The orchard documentation for alternates and placement cover this. There's a good example of this kind of modification on Tony Johnson's Argument Exception Blog.
As per Phil's answer, you need to modify the placement.info in your current theme to use an alternate view like so;
<Match ContentType="BlogPost">
<Match DisplayType="Summary">
<Place Parts_Common_Body_Summary="Content:5;Alternate=Parts_BlogPostSummaryBody"/>
</Match>
</Match>
And then add an alternate part named "Content-BlogPost.Summary.cshtml" in your theme's view folder;
#using Orchard.ContentManagement.ViewModels
#using Orchard.ContentManagement
#using Orchard.Core.Common.Models
#{
ContentItem item = Model.ContentItem;
string title = Model.Title.ToString();
BodyPart bpItem = item.As<BodyPart>();
string linkUrl = Url.ItemDisplayUrl(item);
}
<h4>#Html.ItemDisplayLink(title, item)</h4>
<div class="publishinfo">#Model.ContentItem.CommonPart.PublishedUtc by #Model.ContentItem.CommonPart.Owner.UserName</div>
<div>
<p>#Html.Raw(#bpItem.Text)</p>
</div>
Through reading other post I found that the view responsible for this was Parts_Common_Body_Summary. So I copied this from the core / common folder of orchard and copied it across to my themes view folder, before renaming it to Parts_Blog_Summary
I then set-up a rule for this in Placement.info as follows:
<Match ContentType="BlogPost">
<Match DisplayType="Summary">
<Place Parts_Common_Body_Summary="Content:after;Alternate=Parts_Blog_Summary"/>
</Match>
</Match>
This just left me the task of altering the string length in the new alternate view:
var body = new HtmlString(Html.Excerpt(bodyHtml, 350).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));

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