Copied to clipboard

Flag this post as spam?

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


  • mike 90 posts 258 karma points
    Mar 01, 2015 @ 18:26
    mike
    0

    Plugin View Folder & Namespace Questions

    I have started building a news system for current site (7.2.2) and decided it would be best to have this as an addon so I can re-use it.

    I have created a "NewsPlugin" folder in "App_Plugins". In it created a model and then a surface controller with attribute:

    [PluginController("NewsPlugin")]
    

    I then created a Views folder and added a view but the .cshtml didn't act like a view and I get the error:

    "error 28 the name 'model' does not exist in the current context"

    If I copy the Web.config from the normal Views folder to this new Views folder then the error goes away but I am not sure if that is right thing to do as I have gone through several "tutorials" that all are just basic rewording of the documentation and this is never mentioned.  Did I do this right?

    Also what namespace shall I add these to?  In every tutorial I read the namespace section of code was cut off.

    Right now I have it  "[ProjectName].App_Plugins.NewsPlugin".  Is there a special place for this like Umbraco.App_Plugins or does this not really matter as long as it is unique?

    Sorry to ask such simple questions.  I downloaded several projects trying to find something to use as an example but could not find anyting that used views like I am using them.  Does anyone have any projects they would recommend I look at the source code of to learn how it is done right?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 01, 2015 @ 19:23
    Jan Skovgaard
    0

    Hi Mike

    Sounds like you're trying to add a custom section? Then you can probably benefit from reading through Tim's blogpost here, which is the most up-to-date guide about this http://www.nibble.be/?p=440

    Hope this helps.

    /Jan

  • mike 90 posts 258 karma points
    Mar 01, 2015 @ 23:50
    mike
    0

    Hi Jan,

    I am making SurfaceController to add some logic to a view but organising it in a plugin to make it easily re-usable.  He has a different tutorial on that I read (http://www.nibble.be/?p=250) but he did it by having a seperate project compiling and copying across.  From the documentation on surface controllers it seems I shouldnt have to do that, I should be able to just drop code into folder. 

    I googled why the view wasnt being recognised the the new mvc area and got the idea of copying the web.config which worked.  A lot of posts were talking about updating the main web.config razor versions and various different things.  The documentation and all tutorials didn't mention it so I figured this was not what people were doing which started to bug me.

    Went through about 10 projects from the projects section and none had any views so I got frustrated and stopped.  I guess I need to just keep going through them until I find one lol.  In truth it doesn't really mater, I just tend to get caught up on small details instead of just making something work and worrying about it later.

Please Sign in or register to post replies

Write your reply to:

Draft