Developer forum

Forum » Templates » H1 tags automaticly in main title

H1 tags automaticly in main title


Reply
Hi,

I've got a question regarding H1 tags. I'm using an Ecom module with productgroups.
Every Productgroup has a title, which I made an H1 tag.


Now I want those H1 tags to show in the <title></title>, for SEO purposes.
Is there a way to automaticly put H1 tags in the <title> tag?

Thanks in advance,
Robert Bongers

Replies

 
Nicolai Høeg Pedersen
Reply
That would require a small template add in.

This should do the trick:

01.using Dynamicweb.Frontend;
02.using Dynamicweb.Extensibility;
03.
04.namespace Dynamicweb.Modules
05.{
06.   
07.    [Subscribe(Notifications.eCommerce.ProductList.BeforeRender)]
08.    public class NotificationSubscriber2 : NotificationSubscriber
09.    {
10.       
11.        public override void OnNotify(string notification, NotificationArgs args)
12.        {
13.           
14.            Notifications.eCommerce.ProductList.BeforeRenderArgs BeforeRenderArgs = (Notifications.eCommerce.ProductList.BeforeRenderArgs)args;
15.            if ((BeforeRenderArgs.Products != null) && (BeforeRenderArgs.Products(0).Groups != null)) {
16.                PageView.Current.Meta.Title = BeforeRenderArgs.Products(0).Groups.Item(0).Name;
17.               
18.            }
19.        }
20.    }
21.}

 

You must be logged in to post in the forum