Default Meta Keywords & Description
Is there a way to set default meta Keywords & Description that will be used if no description and/or keywords is entered in the Title & Properties for an individual page?
Hello,
You can try to set them at runtime in case the values are empty. You'll need to create a class that inherits from
Hi, I'm also interested in overriding the SitefinityPageResolver in this way, and I have two questions as a follow up to this:
1. AddPageDirectiveValue() needs a NameValueCollection as the first parameter; is this supposed to come from pageData.Attributes? pageData.Attributes is actually of type IDictionary, so would I need to first convert this to a NameValueCollection type?
2. Once I create a class to override the SitefinityPageResolver, do I need to register my class somewhere in order for it to be used within Sitefinity? For instance, somewhere in the configuration->advanced menu?
Hello Christina,
Here is a sample that shows how to use the pageattributes
var pageAttribs = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
pageAttribs["Language"] = "C#";
this.AddPageDirectiveValue(pageAttribs, "EnableViewState", pageData.EnableViewState, true);
The class should be registered through IoC and our ObjectFactory class using RegisterType method of UnityContainerExtensions inside Global.asax - Application_Start.
Kind regards,
Ivan Dimitrov
the Telerik team
Thanks for the guidance. I'm still a little bit stumped as far as correctly registering my custom class with Sitefinity.
The following code produces causes the error "The type String cannot be constructed. You must configure the container to supply this value" to occur upon load of every page, and the SetPageDirectives() in my CustomPageResolver class is never called.
protected void Application_Start(object sender, EventArgs e)ObjectFactory.Container.RegisterType<SitefinityPageResolver, CustomPageResolver>();
protected void Application_Start(object sender, EventArgs e) Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += Bootstrapper_Initialized;protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)ObjectFactory.Container.RegisterType<SitefinityPageResolver, CustomPageResolver>();
public class CustomPageResolver : SitefinityPageResolver protected override void SetPageDirectives(PageData pageData, DirectiveCollection directives) base.SetPageDirectives(pageData, directives); var pageAttribs = new NameValueCollection(StringComparer.OrdinalIgnoreCase); pageAttribs["Language"] = "C#"; this.AddPageDirectiveValue(pageAttribs, "MetaDescription", "your description"); this.AddPageDirectiveValue(pageAttribs, "MetaKeywords", "your keywords");
Hi Christina,
Try to register the custom page resolver as shown below
ObjectFactory.Container.RegisterType<IVirtualFileResolver, SitefinityPageResolverCustom>("PageResolver",
new ContainerControlledLifetimeManager(), new InjectionConstructor());
OK. I am now doing this to register my type. However, I am still getting the same error message (as follows). Any idea why this might be occurring?
protected void Application_Start(object sender, EventArgs e)
ObjectFactory.Container.RegisterType<
IVirtualFileResolver
, CustomPageResolver>(
"PageResolver",
new ContainerControlledLifetimeManager(),
new InjectionConstructor()
);
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
|
|
Hello,
Any update on this? I tried the same code as mentioned and the custom Page Resolver logic is never invoked. I did run my project through the debugger and the Object Factory Registration does happen but my custom logic is never executed.
Thanks,
Thomas