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?
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
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.
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:
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?
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
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.
is working on a reply...