Copied to clipboard

Flag this post as spam?

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


  • Meni 273 posts 530 karma points
    Apr 10, 2016 @ 16:46
    Meni
    0

    How to convert old dynamicNode razor scripts to partial views

    Hey, just updated to U7 2.x, and need to update one of my Razor scripts - but didn't find them. Then I've find this topic: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/59874-Razor-in-U7Am-I-just-over-tired

    , but couldn't understand where I can find the "old" scripts in order to create the new ones under the MVC macros? Is there any guide? Like, where I find the "old" code? After creating the new scrips - should I delete the old scripts?

    Pls advise. Thanks.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 10, 2016 @ 18:05
    Dennis Aaen
    0

    Hi Meni,

    If you look at the file structure for your Umbraco installation on the server did you still see the Scripting file folder?

    If then your files should still be in this folder :-)

    Hope this helps,

    /Dennis

  • Meni 273 posts 530 karma points
    May 01, 2016 @ 18:45
    Meni
    0

    Hi Dennis, Thanks. Found it. Now have "new" problems though - get lot of errors ... - the scripts apparently doesn't work as "MVC Partial views Macro Files" .

    Here's some of the code I'm using in the "old" Razor scripts:

    @using umbraco.NodeFactory;

    dynamic MyMagazine_node = Library.NodeById(1023);

    var Magazine_pagesToList = @MyMagazine_node.Children.Where("Visible");      
    
    Magazine_pagesToList = Magazine_node.DescendantsOrSelf().Where("NodeTypeAlias == @0", "NewsPage");
    
    Node get_feature_story = new Node(1432);
    string MainNewsStr = get_feature_story.GetProperty("mainNewsItem").Value;
    int MainNewsID = Convert.ToInt32(MainNewsStr);
    
    var feature_story_HP = Model.NodeById(MainNewsID); 
    

    There are more - for now, this a script that doesn't work - what's wrong? Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft