I'm working on a new setup for looping out boxes (or widgets as other would say) on our websites. I'm thinking of using the Widget Grid by Matt and needs ideas to how to do it best. I'm working width two ideas, none of them are optimal i think, so I hope you have some input.
Basically the Widget Grid provides a list of node ID's that I need to render into some markup.
Idea 1 Make one large razor file with one method per document type that I need to handle. I'll then do a switch case on each node and create the markup for that node. The problem is that potentially this file could become quite large if theres a lot of different types of boxes.
Idea 2 Use the RenderTemplate method to render the box as a page this a specific template. This is nice because I can then have separate razor files. The problems are that the RenderTemplate method makes currentPage to the box instead of the actual currentPage. Furthermore I need a template for all box nodes, which I don't in idea 1
How about it. Any other great ideas. I'm not very fond of any of my ideas, but idea 1 will be the one I choose if you guys can't come up with something brilliant.
I'd definitely go with number 1 (not that I'd actually go Razor, u know :-) - the filesize "problem" is just a maintainability problem, right? There's no real impact of a large file when compiled (?)
I do the equivalent in XSLT with separate templates for each Widget type - as soon as the file grows large, I split it into separate files, using an include statement to assemble them (the XSLT is compiled once, so no real penalty here either).
And you know you definitely want currentPage to be the actual page, not the Widget.
Anyway, what do I know about Razor ... :-) There's probably an even better option somewhere...
Thanks for the input Chiztian. That's also what I do with xslt today.
Yes the file size is only a problem because of the maintainability. It's a big "only" in my world though. It will be ugly and not very good practise. So I was hoping some of the Razor fanboys had a better idea. I'm not hooked on razor yet. It's OK but seems to be hard to work with.
Boxes/Widgets with razor
Hi Guys,
I'm working on a new setup for looping out boxes (or widgets as other would say) on our websites. I'm thinking of using the Widget Grid by Matt and needs ideas to how to do it best. I'm working width two ideas, none of them are optimal i think, so I hope you have some input.
Basically the Widget Grid provides a list of node ID's that I need to render into some markup.
Idea 1
Make one large razor file with one method per document type that I need to handle. I'll then do a switch case on each node and create the markup for that node.
The problem is that potentially this file could become quite large if theres a lot of different types of boxes.
Idea 2
Use the RenderTemplate method to render the box as a page this a specific template. This is nice because I can then have separate razor files. The problems are that the RenderTemplate method makes currentPage to the box instead of the actual currentPage. Furthermore I need a template for all box nodes, which I don't in idea 1
How about it. Any other great ideas. I'm not very fond of any of my ideas, but idea 1 will be the one I choose if you guys can't come up with something brilliant.
Thanks
/Rune
Hi Rune,
I'd definitely go with number 1 (not that I'd actually go Razor, u know :-) - the filesize "problem" is just a maintainability problem, right? There's no real impact of a large file when compiled (?)
I do the equivalent in XSLT with separate templates for each Widget type - as soon as the file grows large, I split it into separate files, using an include statement to assemble them (the XSLT is compiled once, so no real penalty here either).
And you know you definitely want currentPage to be the actual page, not the Widget.
Anyway, what do I know about Razor ... :-) There's probably an even better option somewhere...
/Chriztian
Thanks for the input Chiztian. That's also what I do with xslt today.
Yes the file size is only a problem because of the maintainability. It's a big "only" in my world though. It will be ugly and not very good practise. So I was hoping some of the Razor fanboys had a better idea. I'm not hooked on razor yet. It's OK but seems to be hard to work with.
/Rune
You can always do some seperation by using RenderPartial so you don't have ALL the code in one file (better for source control as well):
http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/@renderpage-with-args
Sweet. If that works you are my hero. I have trawled google for that single piece of information. Will check it out right away.
Thanks Sebastiaan.
/Rune
And it works. Once again you save my day Sebastiaan. Thanks a bunch. :)
HFYR
/Rune
is working on a reply...