How to update homepage title only

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hello,

I have created a plugin and it loads correctly and shows up in my Local Plugins page. I have a Class1.cs file inside my plugin project. How do I make my plugin update only the homepage title tag?
5 years ago
I have a view for my plugin configure.cshtml and have this code:

@{
    var Route=HttpContext.Current.Request.RequestContext.RouteData;
    var controllerName = Route.Values["controller"].ToString();
    var actionName =Route.Values["action"].ToString();
    var isHomePage = false;
    if (controllerName == "Home" && actionName == "Index")
    {
        isHomePage = true;
    Html.AddTitleParts("Welcome to the main page");
    }
}

But it does not work.

Should I put this code elsewhere
5 years ago
Well, configure page is for administration, to set something which should be executed from PublicInfo.cshtml
Maybe first, you would be able to set any text in one of system widget zones, instead of removing any part of the page? Also have a look on NivoSlider plugin, which is available also with source code - you may learn from this how to make first steps as nopCommerce plugin developer.

Regards,
Tom
5 years ago
I am able to output text on the page using the H1 but still unable to override the title tag. I can even get script tags to output using Html.AddScriptParts(). Here is my code:

@using Nop.Web.Framework.UI;
@using Nop.Core.Infrastructure;
@using Nop.Web.Extensions;
@using Nop.Core.Domain.Seo;
@using System.Web;
@{
  Layout = "";
  Html.AppendTitleParts(T("test").Text);
}
<h1>TEST</h1>
5 years ago
Would anyone be willing to help out? Thanks!
5 years ago
The view responsible for outputting the title tag is _Root.Head.cshtml.

Simply add an if statement in there which checks to see if the controller and action match the homepage.

If you don't want to edit the view then you'll have to find a way to override @Html.NopTitle() in your plugin. This is probably possible.
5 years ago
Yes, I need to know how to override it. I'm not making any changes to the root view.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.