The yearly Umbraco festival in Sweden was hosted today in Gothenburg and I was one of the speakers. My subject was “The first Umbraco V8-site” and I tried to share some of my learnings from trying to implement a new site with the current “version” of Umbraco v8.

 

Presentation Usf 2018

 

You can download the slides here

This is a quite annoying problem that I sometimes hit with Resharper, some of the times the views are in the “correct” folders and sometimes when we’re using custom locations for the views.


Fortunately it can be fixed.

Use annotations to indicate where views are placed

 

Jetbrains ships a package of annotations that we can use to tell Resharper where our views are placed. Start by referencing the Nuget-package that contains these annotations:

 

 

Install-Package JetBrains.Annotations

 

 

Then in your solution, open the “Properties/AssemblyInfo.cs”-file and add these annotations to indicate for Resharper where you views are placed.

 

[assembly: AspMvcPartialViewLocationFormat(@"~\Views\Partials\{0}.cshtml")]
[assembly: AspMvcPartialViewLocationFormat(@"~\Views\MacroPartials\{0}.cshtml")]
[assembly: AspMvcViewLocationFormat(@"~\Views\{1}.cshtml")]

 

The example above works good with views in Umbraco CMS where some partials are placed in the "MacroPartials"-folder.

There’s three different placeholders that you can use to build the paths:

  • {0} - view name
  • {1} - controll name
  • {2} - area name

 

And there is also different annotations depending on what type of view we are looking for:

 

  • AspMvcAreaMasterLocationFormatAttribute
  • AspMvcAreaPartialViewLocationFormatAttribute
  • AspMvcAreaViewLocationFormatAttribute
  • AspMvcMasterLocationFormatAttribute
  • AspMvcPartialViewLocationFormatAttribute
  • AspMvcViewLocationFormatAttribute


Sometimes you beed to build and reload the projects for this to work.

In this post I just wanted to share some really good extensions for Visual Studio 2017 that I use on a daily basis.

File Nesting

A simple little utility that makes it possible to nest files from the UI, great for ie. web.config files with different versions for release, stage and production.

 

https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting
https://github.com/madskristensen/FileNesting

 

Blog -vs -ext -file -nesting

 

Configuration Transform

This cool utility can test your configuration transform before commiting them, great to test your transforms very fast.


https://marketplace.visualstudio.com/items?itemName=GolanAvraham.ConfigurationTransform
https://github.com/golavr/ConfigurationTransform

 

Blog -vs -ext -preview _diff

 

 

One issue with the current version of configuration transform (3.2) is that it only support configuration files thats placed in the root of project, i've created a pull request that solves this: https://github.com/golavr/ConfigurationTransform/pull/6, so if you nned to work with config files outside of the root - just download and build the version with my fix and place the files in your VS-extentions folder.

 

For Visual Studio 2017 the path is:
%LocalAppData%\Microsoft\VisualStudio\{vs-version}\Extensions\

 

Markdown Editor

Provides a markdown editor inside Visual Studio, great when you want to edit your Github readme.md-files.


https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor

Vs -markdown -preview -window

 

 

I’m not sure if everyone who reads my blog knows that I’m the trainer for the official Swedish Umbraco courses. It was after CodeGarden 2013 that I was asked to help out with the education of developers and designers here in Sweden and I’ve had a lot of fun and made a lot of new friends during these events!

IMG_4170

 

Over the years I’ve had a lot of really smart people attending my courses – but I’ve never had any student regretting that they attended. It does not matter which skill-level you have before you come – there is always something new to learn and to try. A lot of people think of different courses as a way to get certified  and yes – that’s really good and very important. At the same time I really want to point out the greatest value about the courses, that’s all the knowledge  that you can take home and use in all new projects.

 

When I attended the trainings I’ve been working with Umbraco for about 4 years and still I decided to go to the Fundamentals training just to make sure that I haven’t missed anything important. It was some repetition but I got away after these to days with about 10 things did I did not know before – big features in the core that I’ve never used or small tips and tricks that made some tasks trivial compared to how I’ve solved them before.

 

This week the Norwegian developer Lars-Erik Aabech pointed out this with a nice tweet about something as simple as the “Alt Template”-feature of Umbraco.

 

 

A lot of experienced Umbraco developers that have not attended the trainings have probably missed out on this and on stuff like “Recursive properties”. These to thing are just small examples of stuff from the Fundamentals-training that self-thought developers never get to know.

 

So why does the trainings matters?

  • Fastest way to get a compact “smorgasbord” of up-to-date knowledge about Umbraco
  • Don’t miss any details or fundamentals
  • Official certification –  comforting for clients

 

If your in Sweden and thinks about attending a course, have e look here for the next training event!

Today my blog post for 24 days in Umbraco was released. The topic is “The code that changes my life”.

 

24days

 

This is a great Christmas tradition where the community posts one article per day up until Christmas! Head over to the site and read about some really interesting topics for example:

 

 

You’ll find all the articles here: http://24days.in/umbraco/2015/

 

 

uhang-585

 

I finished of last week by participating in Warren Buckley's lovely uHangout. This time I showed my latest package “The Dashboard” which also won this years package competition on CodeGarden 15. The package is a really simple dashboard that can be used to give both editors and developers a better first experience when the log on to their Umbraco backoffice. This is how it looks:

 

635698726453441911_thedasboardpng

 

Please Download The Dashboard and give it a spin! If you would like to contribute (or just leverage the source code) the project is hosted on GitHub: https://github.com/enkelmedia/TheDashboard

 

Our conversation also evolved into an overall discussion about the editor experience in Umbraco CMS and how you as a developer can improve it.

 

If you want to watch the show it on http://uhangout.co.uk/ or on YouTube: https://www.youtube.com/watch?v=fNoHxYSuBXo

 

I’ll try to post a summery of the tips and tricks and the packages that I talk about in the upcoming days.

 

Cheers! =D

Since Visual Studio 2013 update 2 VS includes a nice Json editor that makes is easier to edit files containing json data. By default this editor is only used for .json-files and since the json-formated package.manifest-file used to create new plugins for Umbraco has the manifest-extention Visual Studio won’t add any syntax highlighting.

 

This is easy to fix.

 

1. Go to Tools / Options

2. I the left menu click on Text Editor and then File Extention.

3. Write “manifest” in the upper left text box, choose JSON Editor in the dropdown and click on Add.

4. Hi OK, open your manifest file and – ta da!

 

Vs -manifest -extention

 

PS. If you like the screen recorded GIF (I do) check out this awesome project: https://screentogif.codeplex.com/

 

swetugg

 

February 2-3 next year the Swedish .NET User Group (SWENUG) will host a two day .NET-conference in Stockholm, Sweden.

 

Topics varies around the .NET-space and  I’ve got the honor to speak about Umbraco CMS. I’m planning to do a very short basic intro about Umbraco and then dive into how to extend the editor environment using AngularJS. My experience from showing Umbraco to new users is that the Angular-based property editors really impresses people. My hope is that this session will help to further grow the Umbraco community here in Sweden.

 

If you would like to join, tickets only costs 500 SEK, read more at swetugg.se

 

swetugg-speaker

As long as I can remember Umbraco has shipped with a set of presets for the url replacing feature. This is the feature that takes the node name and turns it into a valid url. These presets lives in the /config/umbracoSettings.config-file and used to look something like this.

 

<urlReplacing removeDoubleDashes="true">
   <char org=" ">-</char>
   <char org="""></char>
   <char org="."></char>
   <char org=";"></char>
   <char org="/"></char>
   <char org=":"></char>
   <char org="+">plus</char>
   <char org="*">star</char>
   <char org="&"></char>
   <char org="?"></char>
   <char org="æ">ae</char>
   <char org="ø">oe</char>
   <char org="å">aa</char>
</urlReplacing>

 

In later versions of Umbraco (I think since Umbraco 7) the urlReplacing element has been removed from the default umbracoSettings.config-file and the presets are hidden. At CodeGarden14 this year I learned very much from Stephans session about the core internals of Umbraco (Slides: http://www.zpqrtbnk.net/CoreInternalsForWebsiteDevelopment.pdf) one thing was the toAscii-property of the urlReplacing-element. Since there is hundreds of different chars that you might want to replace and it’s very likely that you’ll miss some – that why they have included this great little flag. So all the configuration above can be replaced with this simple line:

 

<requestHandler>
  ....
    <urlReplacing toAscii="true" />
</requestHandler>



I had that question in mind when I was working with a new MVC-site using Umbraco 7 and wanted to share my conclusions. Well after some googling I found this great blogpost from the Umbraco core-developer Shannon Deminick. It’s related to Umbraco 5 (RIP) but the concept still applies to the MVC-implementation in Umbraco 7 (and 6), in one of the comments he explains the difference.

 

So. This is the thing.

Use return CurrentUmbracoPage()

When you just want to return the current page. Here you can use the ViewData and ViewBag object to pass data from the controller to the view and that will work just fine. Generally you want to return to the current page if you want to keep the POST-data that was sent to the controller.

Use return RedirectToCurrentUmbracoPage()

When you really want to redirect the user. Shannon’s writes: “If your POST is successful, you shouldn't just return a response, you should redirect to a page so you can avoid the aweful issue of having a user press refresh and have it resubmit the POST”. To pass data back to the view you’ll need to use the TempData-object that will “survive” the redirect.

 

So if you’re creating a form and the model state IS valid, you should perform your actions and RedirectToCurrentUmbracoPage(), if the model is not valid you should just return the CurrentUmbracoPage(). That’s why many examples looks like this:

 

if(!ModelState.IsValid)
   return CurrentUmbracoPage()
// do stuff here
return RedirectToCurrentUmbracoPage()

 

Another thing to notice about the routing is “Just FYI, when you POST to a SurfaceController, you are just posting to your own controller which is outside of the Umbraco process, it is just a very normal MVC post. So when you do a return CurrentUmbracoPage call, that then passes execution back to Umbraco to go lookup the page that was posted from and renders it. You could in theory just return your own View(model) which will be completely outside the umbraco process, because it is just an MVC normal controller.

 

Thanks Shannon for making this clear! #h5yr