I am trying to use the meta description in search results. I have my examine search results from which I get the content node and then try to access the seoChecker property as below.
However, SEO Data is coming back empty and I'm not 100% sure why. Interestingly, if I attempt to inspect the data it is showing a canonical url for the search page and not the content node.
@if (Model.Results.HasAny())
{
foreach (var result in Model.Results)
{
var contentNode = Umbraco.TypedContent(result.Id);
var seoData = contentNode.GetPropertyValue<MetaData>("seoChecker");
[…]
}
}
If I visit the actual page itself the meta tags are getting populated as expected.
When you request a page SEOChecker checks all the info based on the context of the page therefore it's not in the Current Metadata. I have seen some improvements in this area and if you are up for testing this I can see if this can be improved the next coming days.
Yes, I'm up for testing it as its a bit of a show stopper at the moment. Had I known earlier on I would have implemented custom fields to hold that data?
Perhaps I can get the raw property value and serialise it to a MetaData object that allows me to get at what I need?
Check the manual, there is a native Metadata class as well where you can pass in the id. This will work perfectly for Metadata that is stored in the description fields.
But I will follow up on this one later today/tomorrow
Almost refactored the MVC library as well so it's no longer Context aware. Only thing left then is the PropertyEditorConverte that needs to pass in the document Id ;-)
I've Added this to the MVC Metadata object that is responisble for making sure all Metadata for the page is available. It's not possible to use a PropertyEditorConverterfor this since I need the context of the whole page and a node id is missing when converting the value.
Sample below works
@{
var meta = new SEOChecker.MVC.MetaData(your umbraco node id here);
}
@meta.Description //Gives you the Description or default SEODescription
Problems Accessing SEO Data in Search Results
Hi Richard,
I am trying to use the meta description in search results. I have my examine search results from which I get the content node and then try to access the seoChecker property as below.
However, SEO Data is coming back empty and I'm not 100% sure why. Interestingly, if I attempt to inspect the data it is showing a canonical url for the search page and not the content node.
If I visit the actual page itself the meta tags are getting populated as expected.
Any ideas?
Hi Simon,
When you request a page SEOChecker checks all the info based on the context of the page therefore it's not in the Current Metadata. I have seen some improvements in this area and if you are up for testing this I can see if this can be improved the next coming days.
Best,
Richard
Hi Richard,
Yes, I'm up for testing it as its a bit of a show stopper at the moment. Had I known earlier on I would have implemented custom fields to hold that data?
Perhaps I can get the raw property value and serialise it to a MetaData object that allows me to get at what I need?
Thanks, Simon
Check the manual, there is a native Metadata class as well where you can pass in the id. This will work perfectly for Metadata that is stored in the description fields.
But I will follow up on this one later today/tomorrow
Best,
Richard
Duh! Thanks Richard, that works perfectly.
Great to hear,
Almost refactored the MVC library as well so it's no longer Context aware. Only thing left then is the PropertyEditorConverte that needs to pass in the document Id ;-)
Hi Simon,
I've Added this to the MVC Metadata object that is responisble for making sure all Metadata for the page is available. It's not possible to use a PropertyEditorConverterfor this since I need the context of the whole page and a node id is missing when converting the value.
Sample below works
You can download the hotfix via dropbox and this will be part of 2.2.4(+)
Hope this helps,
Richard
Thanks Richard. Your example actually works with my current version of the package without needing an upgrade or hotfix.
Great support for a great package as usual!
is working on a reply...