Forum

The forum is a free service supported by community members. Please consider opening a support ticket if you need timely help.

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 11 Dec 2018 03:00 AM by  Steve L
Retrieve current category image
 5 Replies
Sort:
You are not authorized to post a reply.
Page 1 of 212 > >>
Author Messages


New Member


Posts:58
New Member


--
08 Dec 2018 03:32 AM

    Hi Guys

    Been trying hard to follow models structure in the knowledge base to do various things. Sometimes it makes sense and works. Other times it doesn't.

    For example in the product list template, I can use this to show the ID of the current category:

    @Model.Category.CategoryID

    But if I follow the process further and want to get the URL of the image associated with the current category, it fails:

    @Model.Category.DefaultThumbnailGallery.MediaUrl

    I can't see why that shouldn't work?

    Regards
    Rob

    p.s. is there a way to generate a text file with the complete model structure in it as an accurate reference?

    0


    Veteran Member


    Posts:2955
    Veteran Member


    --
    10 Dec 2018 10:37 PM

    Hi Robert

    The model makes sense for most common use cases that template is intended for. Some templates may not have every data "mapped" to the model. The primary reason is to balance between performance and need for every data. If we start to query every data available and map to the model, it might benefit a few edge cases at the expense of many.

    In the case of the Product List template, you'll find the Model.Category will not have the Gallery model mapped. But its sub-categories, namely Model.Category.SubCategories have them mapped. We didn't expect a use case where you need to display gallery images of the current category itself since in the Storefront admin we currently allow uploading a thumbnail image for the category but not larger sizes. However, we do allow displaying sub-category images like it's shown here in gray-scale.

    Perhaps, you can elaborate a bit more what you're trying to display so we can justify mapping the gallery to the Model.Category object if it makes sense for other users?

    Thank you!

    0


    Veteran Member


    Posts:2955
    Veteran Member


    --
    10 Dec 2018 11:11 PM
    If you want to visualize the data, you can run a local copy of DNN and Storefront on your machine, download and run the free Visual Studio and open the template file under \DesktopModules\Revindex.Dnn.RevindexStorefront\Portals\0\Display\ProductList\TEMPLATE_NAME\Display.cshtml

    (where 0 is your portal ID or _default if it's running the standard template and TEMPLATE_NAME is your template's name) and then set a breakpoint to a line in the code and attach the debugger to it. Visual Studio will stop at the breakpoint allowing you to inspect the object data.

    0


    New Member


    Posts:58
    New Member


    --
    10 Dec 2018 11:54 PM

    Thanks for the reply Stephen

    What I'm doing is building a set of generic templates that contain all relevant functionality, and are nicely styled right out of the box. Then I don't have to spend time building new templates every time I use the store. The relevant functionality is lifted from all the other stores I've built over time.

    The intent in this case was to display the category image when the category is viewed, not just when the parent category is viewed, as it is now. This would work in conjunction with the category name and description to provide a descriptive header section for the categories. Obviously one could insert an image into the description editor, but re-using the already-uploaded category image makes sense. This particular store that I am building my generic templates on is transferring from a zencart site which does exactly this.

    Obviously if the image is only a small thumbnail then it's not necessarily useful as a full header image. Perhaps it would make better sense if it allowed both a category thumbnail and a category header image to be uploaded.

    However, it's not a huge drama if it can't go in. I have a long list of notes I recorded from the build of the first site that is now live and I will be sending those through as a series of bug, suggestion and request tickets in the new year. I can put this one in as a suggestion at that point, and I'll examine the remaining data and see what else would make sense alongside it.

    But I won't hit you with all that this late in the year :)

    Thanks
    Rob

    0


    New Member


    Posts:58
    New Member


    --
    11 Dec 2018 12:23 AM
    Stephen Lim wrote:
    If you want to visualize the data, you can run a local copy of DNN and Storefront on your machine, download and run the free Visual Studio and open the template file under \DesktopModules\Revindex.Dnn.RevindexStorefront\Portals\0\Display\ProductList\TEMPLATE_NAME\Display.cshtml

    (where 0 is your portal ID or _default if it's running the standard template and TEMPLATE_NAME is your template's name) and then set a breakpoint to a line in the code and attach the debugger to it. Visual Studio will stop at the breakpoint allowing you to inspect the object data.

    Hi Stephen

    Should this work directly on my live instance? My server has VS2010 on it and so I've opened my list template through the file menu right there. Then I picked a couple of lines and inserted breakpoints. I get stuck at the next part - attaching a debugger.

    I've watched a couple of tutorials and they seem to go straight from inserting the breakpoints to running the code via 'Start Debugging (F5)'. This menu item is always grayed out so I'm not sure where to go next. Without asking you to write a tutorial, is there something obvious I've missed?

    Regards
    Rob

    0
    You are not authorized to post a reply.
    Page 1 of 212 > >>