0
votes

I got stuck in building an Umbraco 7 website. I made my masters template (header, footer and renderbody) and homepage (contains a custom menu that links to different product pages). I have some knowledge about controllers and models.

In the sql database i have a list of products, each one having properties like cost, description. How can i create this structure

  • Master template
    • Home Page
    • product 1
      • product 1 description
      • product 1 cost
      • product 1 shipping
    • product 2
      • product 2 description
      • product 2 cost
      • product 2 shipping

Each product will have a few child pages (description, cost, shipping), they all look the same (html structure wise), but the data must come form the sql server database. I tried creating folders in umbraco's back-end and putting views there, but i get error messages when trying to navigate to that path (directory url is set to true in web.config).

In the end i need an structure like:

  • / (homepage)
  • /product1/product1description (/product1/ will redirect to this page)
  • /product1/product1cost
  • /product2/product2description (/product2/ will redirect to this page)

I think views is custom folders are good for me, but i can't get that to work. any tips?

1
What is the error message that you get when you are trying to navigate to the path? - droidbot
Another observation, for whatever reason it may be, the structure does not seem to be intuitive. I would use something like Merchello if this is an e-commerce project. - droidbot
I get a simple 404. Page not found. What I want is to create views in visual studio, and group them in folders. I need those folders to build up an certain url path, and views/models to be able to use sql queries. The view works if I keep it at root level, but gives an 404 error if I move it in a folder - Bogdan Mircea Stanciu

1 Answers

1
votes

It seems to me that you need to first get a good understanding of DocumentType and Content; which will generate your "site map" or content structure; it's not quite the same as standard ASP.Net MVC in that Umbraco out of the box handles the Controllers and Models for you; all you need to do is create the Views (Templates) like you have done.

Unless you are creating Partial Views backed by your own controllers (inheritiny from SurfaceController) you shouldn't need to create any further folder structure physically. The "folder" structure you've outlined above should be reflected by your Content tree.

Other notes:

  • @droidbot mentioned using Merchello to handle Product data - if you're building an online store then you may want to consider that; however the documentation is out of date and you may find it easier to implement one of the other Umbraco e-commerce plugins.
  • If your product data is already structured in database tables (and depending on the complexity and volume of data) then you may want to write some code to query it and display it directly in the product template rather than "exporting" it to Umbraco as content or product data in something like Merchello - in that case I recommend you brush up on SurfaceControllers even more. You may want to extend the Umbraco back-office with some custom data types.

Bottom line - brush up on the Umbraco documentation. You'll answer a lot of your own questions about implementation. Subscribing to and going through the video tutorials wouldn't hurt either: