Hi,
How can i change the meta title page in RAZOR?
Hi,
Are you refering to updating item types or refering to something else?
http://developer.dynamicweb.com/documentation/for-developers/item-based-structure/querying-items.aspx
Or are you just refering to the template file, where you display the meta title?
Like this?
<title>
@WhateverRazorCode
</title>
Nicolais example didn't work for me. DW overrides the title.
But this works...
You can extend the title if you include @GetValue("Title")...
<title>@GetValue("Title") - some text here</title>
Or you can replace the title by setting the tag value...
@{ this.Model.Template.SetTag("Title", "my custom title"); } <title></title>
Ah, yes. Forgot that - thank you Morten!
Parsing of the header can also be disabled by adding disableparsing:true to the head tag:
<head data-settings="disableparsing:true">
I tried with disableparsing:true, but it seems like it has no effect on the title element. It works for other meta tags though :)
Another way to do this is by putting @GetValue("Title") (which Dynamicweb looks for and adds if not found) inside a Razor comment:
<title>@GetValue("Item.Name")@*@GetValue("Title")*@</title>
Best regards,
Mikkel
Great solution, Mikkel.
Although, I think the next developer will be scratching his head and wondering what happened when he finds something like that in a template :D
Well, MIkkel's solution works, but you are right. Next developer will have o figure it out :)
You must be logged in to post in the forum