GL Digital Blog (Page 6)

Mocking UmbracoHelper and using it with Dependency Injection

The Umbraco APIs are full of examples where the developers have made tough design choices. The UmbracoHelper is the one, from my own experience at least, in which the reasoning behind the design is not immediately obvious. In many cases, the way the UmbracoHelper was designed is a blessing – enabling seamless use in Razor …

29/01/2017

Dynamic Umbraco Sitemap.xml Without Plugins

It’s easily possible to create a proper sitemap.xml, with the right URL, in a vanilla Umbraco installation with these three easy steps: Create a “XML sitemap” document type and template in the backoffice Add a line in the template for the “XML sitemap” doctype so that Umbraco serves it as XML rather than HTML Configure …

12/10/2016

Import any CSV File into Umbraco with the Umbraco LINQPad Driver

I’ve recently successfully imported data from a large CSV file into Umbraco using Shannon Deminick’s useful Umbraco LINQPad driver. Here’s a high-level overview of how I did it: You can import any valid CSV file through this process, and infact, it would work with any data format parseable in .NET – LINQPad provides a full …

23/07/2016

Comparing Objects in Chai Doesn’t Work as Expected?

Here’s the gotcha of all gotchas. If you compare two objects in Chai with .equal, you’re not going to get what you expected. These two objects are clearly equal, however the test fails: × should equal PhantomJS 2.1.1 (Windows 8 0.0.0) expected { Object (name, species, …) } to equal { Object (name, species, …) …

30/05/2016

Implementing IOC in Umbraco 7- Inversion of Control Like a Boss

I’ve devoted a significant amount of time this week to finding the best way to implement inversion of control for proper dependency injection in Umbraco. After much brow-furrowing and much to-ing and fro-ing with some of the Umbraco devs (shout out to @clausjnsn for all the help) I think I have it. I’m using Autofac …

27/05/2016

Killing Switch Statements in React with the Strategy Pattern

I saw this article about building multi-step forms in React recently – and although it’s a very well-written and organised article, I was concerned about the use of the switch statement in the render() method of a React component here: // file: Registration.jsx var React = require(‘react’) var AccountFields = require(‘./AccountFields’) var SurveyFields = require(‘./SurveyFields’) …

20/05/2016