I have a number of pages within my site that I do not want the <h1> page title to be displayed on (e.g. home page or pages that use a slide as a page title).
I can hide the title shape easily using placement: <Place Parts_Title="-"/>, but the knock-on effect of this is that it prevents the meta title being added to the head section of the page.
Can anyone tell me how to hide the title displayed on the page but retain the meta title, without completely removing the <h1> from the Parts.Title shape?
I have tried targeting the h1 in CSS, but not all content items have selectors that I can narrow it down to.
Any help much appreciated.
Override the TitlePart's shape template, either using the shape tracing tool or by adding a shape template file (Title.cshtml or Title.Parts.cshtml) to your themes Views folder.
The default template is:
#{
Layout.Title = Model.Title;
}
<h1> #Model.Title </h1>
So your new template can have the same code, except for the line with the h1 tag :)
If you want to render different title shape templates for different content types, use Alternates ie. Title.Parts-MyContentType.cshtml is a title shape template only for MyContentType content type.
Your should change Title Part Shape (Like #Szymon Seliga suggests)
But for targeting only specific content you could use placement.info something like that:
<Match Path="~/">
<Place Parts_Title="Header:1;Shape=Parts_Title_OnlyMeta"/>
</Match>
<Match ContentType="NameOfContentType">
<Place Parts_Title="Header:1;Shape=Parts_Title_OnlyMeta"/>
</Match>
Also you need to create alternate like that ~/Views/Parts/Title.OnlyMeta.cshtml
Related
I have a content type, Events, that has a part "StartDate" that I need to show twice in the summary view. Is it possible inside placement.info to render the part in "this" zone AND "that" zone?
Render the zone twice
Probably not through just using the placement.info file but if you edit the .cshtml view you can just render a zone twice.
For a test I just edited my blog detail view to have this code:
#Display(Model.Content)
#Display(Model.Content)
It worked, and displayed it twice. It's something you should probably be careful with this as in that example it rendered out my Disqus comments twice which created a clash because the same id was used twice on a single page.
Fine tune it with Part Relocation
If you need to pull a single bit of content (a shape/part) out of an existing zone you can also do it with something called Part Relocation which is explained in this Orchard Harvest Session.
The basic idea is to use placement to isolate it into its own zone:
<Match ContentType="News" DisplayType="Detail">
<Place Parts_StartDate="MakeUpAZoneName" />
</Match>
(Note: the Match tag is just an example, its the Place you will need to put in whatever match you want)
And then you can render that out in your .cshtml file with #Display() like:
#Display(Model.MakeUpAZoneName)
... other html code ...
#Display(Model.MakeUpAZoneName)
You can't render same shape twice, but simply you can return combined shapes from your driver and render each shape in different zone.
No its not possible, Only the first one in the file placement.info works.
I have a resource in OrchardCMS that I'm displaying through a number of smaller shapes (so that I can adjust the layout order in placement.info).
In the Driver I am returning these parts through the use of returning a Combined(ContentShape(...), ContentShape(...), ContentShape(...)) etc
However I would like the HTML of each of the smaller shapes to appear within an HTML wrapper (such as a div or article or suchlike)
How do I go about doing this?
Thanks
I understand what you are trying to achieve but it isn't really a feasible scenario. A wrapper is applied to a shape and combined returns several shapes. As you say, each shape has an entry in the placement.info file, so you could easily have these shapes within different content zones or zones spread around your page, where a wrapper would just not work. Make sense?
The answer is probably that you need to create an override for the content view of the content type you are displaying and add the stuff you want to put in your wrapper in there. e.g. if your content type is called MyType and the displayed type was detail, your view would be called Content-MyType.Detail.cshtml.
Do you mean an Orchard wrapper (whole new cshtml file), or just a HTML element?
In the latter case you can do in your part view:
#{
var tag = Tag(Model, "article");
}
#tag.StartElement
stuff
#tag.EndElement
If you want to wrap a (common) wrapper around your elements, you can do the following in your placement.info:
<Place Parts_MyPart="Content:1;Wrapper=MyWrapper" />
<Place Parts_MyOtherPart="Content:2;Wrapper=MyWrapper" />
And create a MyWrapper.cshtml:
<article>
#Display(Model.Child)
</article>
We would like our Orchard CMS homepage to contain only widgets and no content items. We have two approaches that work:
One. Create a page, title it Home, and set it as the current homepage. Then use placement.info to hide its parts:
<Match Path="/">
<Match ContentType="Page">
<Place Parts_Title="-"/>
<Place Parts_Common_Metadata="-"/>
<Place Parts_Common_Body="-"/>
</Match>
</Match>
This effectively gives us a homepage that displays only widgets. This approach, though, might confuse end users that add content to the site, because they will still see the "Welcome to Orchard!" page and wonder why its content isn't showing up on the site.
Two. Create a new content type called WidgetContainer, that only has the Autoroute part. Then create an instance of it called Home, and set it as the homepage. This is a better approach.
Is there another way to map www.ourdomain.ca to a container that displays only widgets?
Use this module: https://gallery.orchardproject.net/List/Modules/Orchard.Module.Contrib.Widgets
You can create a content type named Widgets Page for instance and add the widgets container part.
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>
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.