Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

Learn more about...


How can I apply a different skin or partial view to specific topics?

I built a form with some scripting that differ slightly from the rest of our site. I thought the easiest way to handle this would be to apply a different skin to the topic containing the form, but I can't find a way to do that. The TemplateSwitching setting only pertains to products and categories, not topics. There's a template option in the topic editor, but that only allows html files and this form uses external css and javascript.

The how-to site mentions using "a partial view to add logic around that section of the layout" whenever you have slight display differences on specific pages, but, again, I'm not entirely sure how to do that and I can't find any pages that go into detail about using partial views.

When I looked for threads on here related to what I'm trying to do, I saw several mention overriding some settings in a driver.aspx.cs file – like this one, but I don't see that in our site's directory anywhere. Am I on the right track?

I admit, I've played with HTML/CSS, Javascript, and PHP, but I'm not at all familiar with asp.net. So, it's possible answer has been staring me in the face this entire time and I just haven't noticed.

asked Aug 24, 2017 in MultiStore by gesturepoke (210 points)
edited Aug 24, 2017 by gesturepoke

2 Answers

0 votes
You don't say what version you're on, but if you're not seeing a 'driver.aspx.cs' file on your site then I'm going to guess v10 and answer for that.

Topics are just content areas that can be embedded in other pages.  While hitting t-whatever.aspx will load a page that contains just a topic, it's not really a 'topic page'.  That's a long way around of saying that unfortunately you're looking at this backwards - you don't need to assign a skin to a topic, you need to make a different skin and display a topic on one of its pages.

I can't think of any way of doing this that wouldn't require some terrible hacks.  There are a few ways to force a page to display with a different template (skinid querystring, linking to a morestore with a different skin, etc) but none of them handle switching back when the customer leaves the page.

Are the changes you're making just in CSS & JS?  It's generally considered bad form, but you could put them directly in the topic itself in style and script blocks, to override what's already on the page.
answered Aug 25, 2017 by Vortx ScottS (13,500 points)
Yeah, I'm using version I forgot to mention that earlier.

I uploaded the CSS and JS files to the server and linked to them within the topic – like you would with a basic html page. So far, it appears to be working. It's along the lines of what you suggested, but I didn't want to use script/style blocks because I felt like there was too much code for that.

I think that may be what I do for forms and specific topics going forward. Thanks for the response.
0 votes

If you can't customize the model for views and a a field for topics then adding the code below to \Web\Views\Topic\Detail.cshtml should do what you want.

    if (Model.Name == "topicname")
        Layout = ViewEngines.Engines.FindViewPath(ViewContext.Controller.ControllerContext, "_Layout-topic");

If you can customize the model and fields then you can make it bit more modular and not have multiple if statements in the view.

Hope this helps.

answered Aug 30, 2017 by mmcgeachy (5,045 points)
This is closer to what I need. Would I copy the code word-for-word, or should I repalce "topicname" with the name of the given topic? And if it's the former, is there a way to check for a specific topic name instead?

You would replce the "topicname" with the name of the topic in this case.

I don't fully under stand specific topic part of you question. Mainly since the logic is changing the layout if the topic name is equal to that excatly topic name only. If you mean part of the name then an if statment like below should apply the template to all topics containing forum in the name.

if (Model.Name.Contains("forum"))