Closed akeilox closed 9 years ago
Hi!
Thank you!
Hmm. Could it be a typo in the docs?
Try this: var seo = this.Model.Content.GetPropertyValue
I'm getting the same error. when i just output @seo i see { "title": "SEO title", "description": "this is the description" } on the page, but it looks like @seo.Title throws an error. is there a using statement or something that i'm missing?
Hi!
Try this.Model.Content.GetPropertyValue
Does that work?
using that gives me this error:
'object' does not contain a definition for 'Description' and no extension method 'Description' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
if anybody else tries to use this and has the same issue, here's the solution:
add using statements to your view:
@using Umbraco.Web @using Newtonsoft.Json.Linq
then parse the object to JObject:
var seo = JObject.Parse(this.Model.Content.GetPropertyValue("seo").ToString());
then get the values like this:
@seo.GetValue("title") @seo.GetValue("description")
CodeAbuser's solution works, just make sure to check for empty values first(and remember those using statements!). Here's what I did, but you probably should set the value as a variable first so you don't have to get it twice... if (!String.IsNullOrEmpty(this.Model.Content.GetPropertyValue("seo").ToString())) { var seo = JObject.Parse(this.Model.Content.GetPropertyValue("seo").ToString()); meta name="title" content="@seo.GetValue("title")" meta name="description" content="@seo.GetValue("description")" }
I left off the meta tag brackets so they would show up in the comment
Hi!
Since we added the property value converters you can use it like this:
@(this.Model.Content.GetPropertyValue<SeoValues>("seo").Description)
or like this
@{ var seo = this.Model.Content.GetPropertyValue<SeoValues>("seo"); }
@seo.Description @seo.Title
The <SeoValues>-part of the lines where stripped from documentation (readme.md) by github so I hade to change to < and > in the markdown.
Sorry about this simple mistake. Hope this helps!
does this require downloading a new version or can i use this now? What using statement do i need to be able to resolve the SeoValues object?
You should be able to use the current version. Just include the namespace "SeoVisualizer"
@using SeoVisualizer;
That gives me an error. namespace not found
Strange - do you have the dll in the bin-folder? If not - download the latest version from our.umbraco.org and install it again.
i did not have the dll. i upgraded to the latest version and the dll is there now and your example works. thanks!
I came across this and was excited about the use-case for editors to preview and edit SEO title and description with preview. However when i try to use the code as specified (the second one), it throws error as below. This code is on a template (umbraco 7.1.6); The property is named seo in the assigned page.
Compiler Error Message: CS1061: 'object' does not contain a definition for 'Title' and no extension method 'Title' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Source Error: Line 28: @{ var seo = this.Model.Content.GetPropertyValue("seo"); } Line 29: Line 30: @seo.Title @seo.Description