Specifiy page Meta Title

Topics: Writing modules
Developer
Jul 28, 2011 at 5:47 PM

How can I specifiy the Meta Title of the page from a module ?

I'd like to add this functionnality to a module similar to Vandelay.Meta that already have Description and Keywords.

Coordinator
Jul 29, 2011 at 1:13 AM

Why don't you expand on the code from that module?

Developer
Jul 29, 2011 at 12:35 PM

OK, I dit it :

- Add a new Property Title in 

- Add a column in Migration.cs

- Return a shape in Driver/Display : Parts_Meta

- Add a view Parts.Meta.cshtml :

@{   
if (!String.IsNullOrEmpty((string)Model.Title)){
       Layout.Title = Model.Title;
   }
}

- Add code in 'EditorTemplates/Parts/Meta.cshtml' to edit the Title :

<div class="editor-label">@Html.LabelFor(model => model.Title)</div> 
<div class="editor-field">@Html.TextBoxFor(model => model.Title, new { @class = "large text" })   
@Html.ValidationMessageFor(model => model.Title)  </div>

- Add <Place Parts_Meta="Meta:1"/> in placement.info (Even it doesn't diaply anything, "-" would prevent to use it)

Coordinator
Jul 29, 2011 at 9:18 PM

Does it work?

Developer
Jul 29, 2011 at 11:29 PM
Edited Jul 29, 2011 at 11:30 PM

Yes. I also added this in placement.info, or else the page title of the summary was the meta title of the last post displayed :

<Match DisplayType="Summary">
        <Place Parts_Meta="-"/>
</Match>

I'll send you the project if you want.

Coordinator
Jul 29, 2011 at 11:33 PM

Sure. I have an update cooking, I'll be happy to add this. Thanks.