Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 11 of 11

Thread: Different Template for Product pages

  1. #1
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Question Different Template for Product pages

    Hi,

    I am using ASPDNSF 9.1 and new to ASP.Net (this is my first ASP.Net project).

    I was wondering how I can have the product pages pull a different template?

    all the pages will have the same template, the only difference between the product pages is that I would like to display the categories box on the left.

    Thanks

  2. #2
    ROBB is offline Senior Member
    Join Date
    Jun 2011
    Location
    United States
    Posts
    107

    Default Product Page Skin Template

    omairkha - yes it is possible to use a different template for product pages, and there are a couple of ways to do so. You can configure the site to use a given template site-wide, or you can assign a template on a per page basis. The latter method (per page basis) would entail assigning a template for each individual product.

    Site-Wide Product Template
    This route will require a slight modification to your showproduct.aspx.cs file. Inside the file, you will find a method called OverrideTemplate(). This method is responsible for returning the string value (name) of the template to be used. You could easily hard code a string value (template name) to be returned.

    For example, in place of
    C#/VB.NET Code:
    return base.OverrideTemplate(); 
    You can have:
    C#/VB.NET Code:
    return "ProductTemplate.master"
    If you wanted to get "fancy", you could implement logic to pull the value from an appconfig, and/or use a certain template on a per store basis. You may also want to consider the order of operations, so that a product template could be used site wide, while still allowing individual page templates to override, if necessary.


    Individual Page Template
    Setting a template on a per page basis could be beneficial, or tedious, depending on what your end goal is. For example, if you would like to create a special promo template for a product, this method would work best. On the other hand, if you have hundreds of products that need to the same template - I would not generally recommend taking this route - as it would entail creating an appconfig for every one of those products.

    The instructions are documented in this article of the AspDotNetStorefront manual: http://manual.aspdotnetstorefront.co...in-a-site.aspx. See "Template Switching" and "Individual Page Templates".


    Hope that helps. If you have any questions, please let me know.
    Cheers ~ Rob
    Last edited by ROBB; 09-26-2011 at 02:59 PM.

  3. #3
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Default

    Hi Robb-

    Thank you again for the help. I have got it working now!

  4. #4
    danrawk is offline Member
    Join Date
    Apr 2011
    Posts
    45

    Default

    hi -
    have you been able to use this site-wide method for 9.2? i tried Robb's instructions but could not get any change to take effect on the product page level.

    so my site would look like this:

    homepage.master: left menu
    template.master: left menu
    producttemplate.master - NONE


    thanks
    dan
    Last edited by danrawk; 09-27-2011 at 10:25 AM.

  5. #5
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Default

    Try this:

    1) In the admin panel go to Organization > Manage Categories

    2) Click on the edit icon for one of your parent categories

    3) Click on the Extension Data tab

    4) Enter the template file name in the "Use Skin Template" field you want everything under that parent category to use. Ie. productTemplate.master

    5) Click Update

    All of the sub categories and product pages under the parent category you just modified should use the productTemplate.master now.

    You will need to do the same for every parent category you have.

    The template file should be in your App_Templates/Skin_?/ folder
    Last edited by omairkha; 09-27-2011 at 10:21 AM.

  6. #6
    danrawk is offline Member
    Join Date
    Apr 2011
    Posts
    45

    Default

    Quote Originally Posted by omairkha View Post

    4) Enter the template file name in the "Use Skin Template" field you want everything under that parent category to use. Ie. productTemplate.master
    The template file should be in your App_Templates/Skin_?/ folder
    thanks, but i don't think this will work. first, it assumes TemplateSwitching.Enabled is set to true. and when you do this, the template carries down to the product level. i'm trying to get rid of a left menu nav, not add one. per the manual, product views from a template specified here will inherit the template.

    i need:
    homepage.master: left menu
    template.master: left menu
    producttemplate.master - NONE

  7. #7
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Default

    Yes, sorry about that. You need to set TemplateSwitching.Enabled to true.

    This is how I did mine and it worked out great.

    Just make a copy of your template.master and call it producttemplate.master

    Then remove that left nav that you do not want from the producttemplate.master

    So basically, you will have everything the same between template.master and producttemplate.master except for that producttemplate.master will have the code to display the left nav you don't want removed.

    For example:

    If you don't want the categories left nav in producttemplate.master then delete the following lines:

    Code:
    <aspdnsf:EntityControl ID="ctrlEntityCategory" runat="server" Header="<%$ Tokens:StringResource, AppConfig.CategoryPromptPlural %>"
                        EntityType="Category" MaxMenuSize="<%$ Tokens:AppConfigUSInt, MaxMenuSize %>" />
    Last edited by omairkha; 09-27-2011 at 10:31 AM.

  8. #8
    danrawk is offline Member
    Join Date
    Apr 2011
    Posts
    45

    Default

    hi -
    thanks again for the reply, but this doesn't make sense. if you did this via template switching as per above, there is no where to apply the product level template. the override template specification doesn't exist in the product extension tab. it's only in categories. now, if i applied a "no left nav" to the override, it would remove it from the category page and the product page , but that doesn't solve the problem.

    homepage.master: left menu
    template.master: left menu
    producttemplate.master - NONE
    Last edited by danrawk; 09-27-2011 at 11:02 AM.

  9. #9
    omairkha is offline Member
    Join Date
    Aug 2011
    Posts
    89

    Default

    It seems like the products inherit the template from the categories they are mapped to. All I did was change the template of the Parent Category and all of the sub categories and all of the products mapped to that category and related sub categories are using producttemplate.master

  10. #10
    danrawk is offline Member
    Join Date
    Apr 2011
    Posts
    45

    Default

    thanks - don't think that solves the issue. hopefully Robb can chime in.

  11. #11
    mikecali is offline Junior Member
    Join Date
    Oct 2009
    Posts
    12

    Default product template

    It seems that you need to remove everything in

    protected override string OverrideTemplate()
    except
    return "templateproduct.master";

    (in the showproduct.aspx.cs file)

    also, the templatename field in the product table does nothing.

    how would you have different product templates per store?

    -Mike