Copied to clipboard

Flag this post as spam?

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


  • David Conlisk 432 posts 1008 karma points
    Nov 12, 2013 @ 16:33
    David Conlisk
    0

    Saving a template in v6.1.6 with umbraco item causes template to disappear from file system

    Hi all,

    A strange one, this. If I create a template called "test" with this content via the Umbraco interface:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    

    a test.cshtml file is created in /Views/ folder in my Umbraco site (as expected). If I then update the contents to this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    <umbraco:Item field="pageTitle" useIfEmpty="pageName" runat="server"/>
    

    and save it using the Umbraco interface, then the file disappears from the file system. I've reduced this to the simplest case possible, but you can see why this might cause problems in a site with templates disappearing!

    Any ideas on what's going on here, and should I be logging this as a bug?

    Thanks,

    David

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Nov 12, 2013 @ 17:45
    Martin Griffiths
    1

    Hi David

    I cant answer why it's causing your file to disappear, but my suspicion is it's because Umbraco is getting confused because you've included WebForms mark-up.

    There's no runat=server in MVC!

    Instead you would use a helper method

    You first start by opening a code block...

    @{ ..... }

    Inside the block add @Umbraco.Field("fieldName")

    You write razor (a form of C#) in MVC so you'll need to do some tutorials on the programming methodologies and syntax.

    Regards

    M.

  • David Conlisk 432 posts 1008 karma points
    Nov 12, 2013 @ 17:52
    David Conlisk
    0

    Hi Martin,

    Thanks for the response, makes perfect sense. I'm just converting some existing web forms templates to MVC which is why I've got this - will take a bit of getting used to the syntax.

    However, still doesn't explain why the template disappears from the file system, which seems like a major issue to me.

    Cheers!

    David

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Nov 12, 2013 @ 17:55
    Martin Griffiths
    1

    If you have a mix of MVC and Webforms (masterpages) in your build and they happen to have the same alias (effectively filename in your filesystem). One will cancel the other out. 

    Although I cant remember which one bites the dust! MVC or WF lol.

    Regards

    Martin

  • David Conlisk 432 posts 1008 karma points
    Nov 12, 2013 @ 17:58
    David Conlisk
    0

    Makes sense, but not what's going on for me at the moment. I'm copying templates from a web forms build into a separate MVC Umbraco project. Seems weird that having a runat="server" would just cause the template to disappear completely. I suppose it keeps things interesting ;)

Please Sign in or register to post replies

Write your reply to:

Draft