Show Welcome Message on Home Page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 years ago
Following my post on http://forums.nopcommerce.com/forums/default.aspx?g=posts&t=290 I thought it would be easier enough to make whether or not the welcome message should be visible a configurable property (like the other elements). So patch below:

--------------------------------------------------------------------------------------------------------------

Create new control /Modules/HomePageText.ascx

Move current static welcome page text from Default.aspx into HomePageText.ascx.

No code is required but control should be in namespace NopSolutions.NopCommerce.Web.Modules for consistency.

Add the control to default.aspx in place of the existing static content. Use the same tag naming/prefixing as other controls:

To register control:

<%@ Register TagPrefix="nopCommerce" TagName="HomePageText" Src="Modules/HomePageText.ascx" %>


And add the control to the page:

<nopCommerce:HomePageText ID="ctrlHomePageText" runat="server" />


In the code behind (Default.aspx.cs), add the following code to the BindData() event:


bool showWelcomeMessageOnMainPage = SettingManager.GetSettingValueBoolean("Display.ShowWelcomeMessageOnMainPage");
if (!showWelcomeMessageOnMainPage)
{
  ctrlHomePageText.Visible = false;
}


Next add a new setting within admin gui in etc settings:

Name: Display.ShowWelcomeMessageOnMainPage
Value: True
Description: Determines whether or not to show the Welcome message content on the home page.


Reason:

As all the other elements of the home page can be controlled within the application (show news / categories etc.) it would be good to have the same configuration for the home page static content.
By moving the static content into an external control it makes it easier to update so that it will not interfere with other elements on the Default.aspx page.

--------------------------------------------------------------------------------------------------------------

All tested working okay.

Ben.
15 years ago
Thanks, Ben!
15 years ago
Does the module HomePageText.ascx have to be created using VS? Or can another module be copied and modified?
15 years ago
if pm me your email address i can send you the control - although you could just copy another one as there is no code behind required.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.