Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Feb 09, 2013 @ 08:33
    Warren Buckley
    0

    V6: What are the differences between Partial View Macro File and a Razor Macro?

    Hello all,
    I wanted to know if anyone knew the differences between using a Partial View Macro and a Razor Scripting Macro in Umbraco V6?

    What are the benefits of using one over the other, as to me at the moment I don't see how to make the best use of out it?

    Cheers,
    Warren

  • Amir Khan 1284 posts 2741 karma points
    Feb 11, 2013 @ 16:54
    Amir Khan
    0

    Were you able to get any insite on this subject Warren? I'm curious also.

  • Drew Garratt 44 posts 192 karma points
    Mar 21, 2013 @ 10:31
    Drew Garratt
    0

    I was just wondering the very same thing. Could anyone shed any light on what the best practice going forward should be?

  • Pavel Gurecki 55 posts 158 karma points
    Mar 27, 2013 @ 16:52
    Pavel Gurecki
    0

    Same question here

  • Barry Fogarty 493 posts 1129 karma points
    Mar 27, 2013 @ 18:26
    Barry Fogarty
    0

    You will find that most of the time you will get away with not having to create Macros at all as you can either write the Razor directly in the template or include a Razor Partial View. Macros with MVC will most likely only be needed when you want to allow editors to insert functional blocks into the rich text editor or when you need to include a form (Child Action Macro) in the page.  

    Source: http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx

  • Drew Garratt 44 posts 192 karma points
    Mar 27, 2013 @ 18:32
    Drew Garratt
    0

    Hi Barry,

    Sounds like Partial Views should make a good go-to alternative for code that won't be accessed by the editors. But I'm curious, will the same caching abilities apply to partial views? With Marcros it's possible to catch the result of pages even on query string driven pages. In a search routine for a large site this kind of caching is invaluable, will the same apply to partials?

  • Barry Fogarty 493 posts 1129 karma points
    Mar 27, 2013 @ 18:47
    Barry Fogarty
    0

    Hey Drew.  Its a good question.  You can use the

    @Html.CachedPartial("MyPartialName", new MyModel(), 3600 

    syntax. Check out the details in the documentation:

    http://our.umbraco.org/Documentation/Reference/Mvc/partial-views

    I'm not completely sure of caching based on the querystring, but hopefully with a bit of playing around you can achieve when was possible in v4.  FOr others not aware of this, Matt Brailsford has an excellent post on caching by querystring:

    http://blog.mattbrailsford.com/2011/02/01/caching-an-umbraco-macro-by-querystring-parameter/

     

  • Drew Garratt 44 posts 192 karma points
    Mar 28, 2013 @ 14:01
    Drew Garratt
    0

    Hi Barry,

    I'd found the cache setting for Partials in the refrecene but it was the following statement that gave me pause;

    "So you can specify to cache by member and/or by page and also specify additional view data to your partial view. HOWEVER, if your view data is dynamic (meaning it could change per page request) the cached output will still be returned, this same principle goes for if the model you are passing in is dynamic. Please be aware of this as if you have a different model or viewData for any page request, the result will be the cached result of the first execution."

    I read that to mean that although you can pass in viewdata IE 

    @Html.Partial("YourPartialName", new ViewDataDictionary{{ "age",33},{"name","peter"}})

    If that data changes the cache will still return the original view render rather than anything changed meaning. For instance if you where to use query string data when that value changes the view output from the cache wouldn't reflect that change.

    I'm certainly going to experiment but it looks to me that I'll have to stick to Macro rendering for those routines which are dependant on dynamic data for the time being.

  • Niclas Lindqvist 48 posts 127 karma points
    Apr 05, 2013 @ 10:55
    Niclas Lindqvist
    0

    Hi guys!

    Is there any way to "release the cache"? I have to restart my app pool for every change i make to my partials right now, it's quite tedious!

  • Rich Green 2246 posts 4008 karma points
    Apr 05, 2013 @ 11:13
    Rich Green
    0

    Publishing (any node) is supposed to release the cache I seem to remember.

  • Ernesto Chavez 3 posts 23 karma points
    May 30, 2013 @ 03:52
    Ernesto Chavez
    0

    From this issue report I see that regular razor macros will become obsolete and are now just for backward compatibility, whereas Partial View Macro will become the new standard for passing parameteres around, etc.

    Src: http://issues.umbraco.org/issue/U4-1681

Please Sign in or register to post replies

Write your reply to:

Draft