You have no items in your shopping cart.

Sunday, December 22, 2024 1:20:54 PM

different stylesheet for second store

Posted: 10 years ago

#266 Quote
Hello again-

I'm working on the theme for my new second store and want to also style my articles pages differently than my first store.

/ArticleRead/List.cshtml
/ArticleRead/ArticlePost.cshtml

Is there a "StoreID" variable available on these pages that I can look for and set to use a different stylesheet?

For example:

if (StoreID==1)
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store1-styles.css");
}
else
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store2-styles.css");
}




Thanks,
Steve

Posted: 10 years ago

#267 Quote
Or maybe it is best to just use host headers to determine which stylesheet to use?

Something like this?

currentstore = Page.Context.Request.Headers.GetValues("Host");

if (currentstore == 'OriginalStoreDomainName.com')
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store1-styles.css");
}
else
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store2-styles.css");
}

Thanks for your help!
Steve

Posted: 10 years ago

#268 Quote
steveembry66@gmail.com wrote:
Or maybe it is best to just use host headers to determine which stylesheet to use?

Something like this?

currentstore = Page.Context.Request.Headers.GetValues("Host");

if (currentstore == 'OriginalStoreDomainName.com')
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store1-styles.css");
}
else
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store2-styles.css");
}

Thanks for your help!
Steve


I tried this, but it did not work...I got this error in log:

c:\inetpub\wwwroot\mywebsite\Plugins\FoxNetSoft.Articles\Views\ArticleRead\List.cshtml(11): error CS1012: Too many characters in character literal

The details for the log entry.Full message:  System.Web.HttpCompileException (0x80004005): c:\inetpub\wwwroot\mywebsite\Plugins\FoxNetSoft.Articles\Views\ArticleRead\List.cshtml(11): error CS1012: Too many characters in character literal at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext cont

Posted: 10 years ago

#269 Quote
OK...nevermind....I finally figured out a solution:


I replaced this line on those two views:

  
  Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/styles.css"); 



...with this code:


string currentstore=HttpContext.Current.Request.ServerVariables["HTTP_HOST"];


if (currentstore == "www.mydomain.com")
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/styles1.css");
}
else
{
        Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/styles2.css");
}




Posted: 10 years ago

#270 Quote
I forgot about the ArticlePostPrint.cshtml

I also need for it to have it's own styling, and the second store's logo to appear on it.

I have written this code for that view, but it is not working:

@{
string currentstore=HttpContext.Current.Request.ServerVariables["HTTP_HOST"];


if (currentstore == "www.mydomain.com")
{
<link href="/Plugins/FoxNetSoft.Articles/Styles/styles-print.css" rel="stylesheet" type="text/css" />

string imgsrc="/content/images/uploaded/store1_Logo_Print_Friendly.jpg";
}
else
{
<link href="/Plugins/FoxNetSoft.Articles/Styles/styles-NATURALS-print.css" rel="stylesheet" type="text/css" />
string imgsrc="/content/images/uploaded/store2_Logo_print_friendly.gif";
}

}


But I get this error in log:

error CS0103: The name 'imgsrc' does not exist in the current context

I suppose it is because that "imgsrc" string is defined inside of a code block, and it doesn't see it further down the page??

Can this be done?

Thanks,
Steve

Posted: 10 years ago

#271 Quote
Actually, only the imgsrc variable I create is the problem, because the error is further down the page, where I call it:

<a href="@Url.RouteUrl("HomePage")" class="logo"><img  alt="" src="@imgsrc"></a>

Posted: 10 years ago

#272 Quote
Problem solved. This is the code I used on ArticlePostPrint.cshtml:

I changed this:

<link href="/Plugins/FoxNetSoft.Articles/Styles/styles-print.css" rel="stylesheet" type="text/css" />


...to this:

@{
string currentstore=HttpContext.Current.Request.ServerVariables["HTTP_HOST"];
string imgsrc="";
string alttag="";

if (currentstore == "www.mydomain.com")
{
<link href="/Plugins/FoxNetSoft.Articles/Styles/styles-store1-print.css" rel="stylesheet" type="text/css" />
imgsrc="/content/images/uploaded/store1_logo.jpg";
alttag="Store 1 Name";
}
else
{
<link href="/Plugins/FoxNetSoft.Articles/Styles/styles-store2-print.css" rel="stylesheet" type="text/css" />
imgsrc="/content/images/uploaded/store2_logo.jpg";
alttag="Store 2 Name";
}

}



Then, below that, I changed this:

<a href="@Url.RouteUrl("HomePage")" class="logo"><img  alt="Store 1 Name" src="/path/to/my/images/store1_logo.jpg"></a>


...to this:

<a href="@Url.RouteUrl("HomePage")" class="logo"><img  alt="@alttag" src="@imgsrc"></a>

Works perfectly-

Steve

Posted: 10 years ago

#273 Quote

Support

Posted: 10 years ago

#273 Quote
Ok.

Posted: 10 years ago

#274 Quote
I think this is the right solution, but for people with more than 2 stores, you would need to use if/elseif logic, or in the case of more than 5, maybe a case/switch for better readability.

Maybe at some point, the option for having a separate stylesheet could be added into the plugin configuration as a feature?

..this would at least allow for simple design differences to the List.cshtml, Search.cshtml, and ArticlePost.cshtml views for each store. For most users of the plugin, this would be sufficient.

The "Printer-friendly" version (ArticlePostPrint.cshtml) is different, and already requires manual customization for most people anyway to make it more or less "friendly". (e.g: removing related product-box's and adding their company logo)

Anyway...we love the plugin and appreciate your continued efforts to provide needed functionality!

Steve

Posted: 10 years ago

#275 Quote

Support

Posted: 10 years ago

#275 Quote
I recommend you to copy css from
~/Plugins/FoxNetSoft.Articles/Styles/store1-styles.css
to your main site css file and remove line
Html.AddCssFileParts("~/Plugins/FoxNetSoft.Articles/Styles/store1-styles.css");


One css-file is best practice. You will have best performance and more simple logic.

Customer opens homepage - loads main css-file.
Customer opens another page - doesn't load css-file. He has css-file from homepage.

Posted: 10 years ago

#276 Quote

Support

Posted: 10 years ago

#276 Quote
About ArticlePostPrint.cshtml.
I'll see.

Powered by nopCommerce

Copyright © 2023 FoxNetSoft. All rights reserved