Hi, I am trying to autogenerate the content for the meta-description property on my Page Type with the fist sentences of the Body Property content. This will ocurr if the meta description property was left empty.
I achived this by adding some code to the master page to collect the text from the property and add a meta-description tag to the page.
But this is probably not the optimal way to solve this issue. My first thought is that if I can do this at the time of saving a new page, this means taking the desired text and actually saving it in the meta-description property would be a better solutiion. At least I would not need to call my function to generate the tag everytime a page is loaded.
Any thoughts on how to achive this and would it have to be made for every single page template file?
I would go with the approach you are using at the moment. Otherwise the content on the page can change without the meta description being resaved. If you still want to do it the other way you can attach an event to DataFactory.Instance.PublishingPage and work you magic there.
Hi Erik, thanks for the reply. I will stick with the current solution since the second one has the problem of keeping the text up to date.
If you are doing some very heavy processing on the text (which I doubt you are) you could cache the processed context with a cache dependency to the PageData (call DataFactoryCache.CreateDepencency to get a dependency to use) and you'd probably improve performance while making sure the meta description is updated when the page is.
As you mention I am not doing any heavy processing on the text. Thanks for the tip Magnus.