40
Kentico Developer Issue 4 January/February 2010 PowerShell and the Kentico API Introducing Thom Robbins

Kentico Developer Issue 4

Embed Size (px)

DESCRIPTION

Kentico Developer is a monthly periodical devoted entirely to developing within Kentico, and to the thriving community of Kentico professionals.

Citation preview

Page 1: Kentico Developer Issue 4

Kentico DeveloperIssue 4 January/February 2010

PowerShell and the Kentico API

IntroducingThom Robbins

Page 2: Kentico Developer Issue 4
Page 3: Kentico Developer Issue 4
Page 4: Kentico Developer Issue 4

FEA

TUR

ES

14 Command line KenticoFor all of those common tasks that you catch yourself running

day in and day out, Martijn Schiferli presents a way to script

Kentico.

20 On Not Boiling the OceanIntroducing our latest contributor sees me also intro-duce one of the biggest things to happen to Kentico within the last couple of years - Thom Robbins.

32 JW PlayerRalph Spandl writes about his latest coding efforts and ow these

can be used to improve the out of the box video player offered

by Kentico.

26 FA(Client)QCandice Pendergast introduces some of the more useful aspects

of the Kentico Partner Portal in relation to frequently asked cli-

ent questions.

28 Ten Things on 5.0Jeroen Furst highlights 10 things in Kentico 5.0 that make life

working with Kentico so much easier for developers and ad-

mins alike.

Page 5: Kentico Developer Issue 4

REG

ULA

RS

6 My DeskRichard Pendergast writes about the flurry of activity that is the

Kentico community. Bring on the critical mass.

10 NewsCandice Pendergast covers the latest movements and happen-

ings in and around the Kentico world.

24 ShowcasesFive of the latest and greatest new sites developed with Kentico

reviewed by Richard Pendergast..

36 Tips and TricksMatt Lee introduces the Kentico SQL views and demonstrates

new ways of using them.

Published by

Not At All strANge Pty ltd

AbN 91 125 365 979Po box 353 MeNAi

NsW AustrAliA

eNquiries

subscriPtioN eNquiries: [email protected]

editoriAl eNquiries: [email protected]

AdvertisiNg eNquiries: [email protected]

coPyright keNtico develoPer 2010WWW.keNticodeveloPer.coM

Page 6: Kentico Developer Issue 4

When I started Kentico Developer way

back when, there was very little in the

way of good quality Kentico commen-

tary available on the web.

Now it seems that every Kentico

expert out there has something to say,

and is out there actively saying it.

It’s great stuff. I don’t know what

has inspired it, but I’m loving it.

The new Kentico initiatives are

really drawing the best of the best out

of the woodwork and placing them on

show.

The Site of the Year Award, the

MVP award, the new Partner Program

incentives, the introduction of a Product

Evangelist - It all seems to be working.

The community is alive with new

white papers, regular webcasts, intro-

ductory videos, blog posts, and press

releases.

Partners are beginning to talk to

each other and share ideas, techniques,

and approaches.

This is a great time to be on board,

and I’m eagerly looking forward to

watching the critical mass roll in, when

we will finally begin to see Kentico

forums outside of DevNet, Kentico user

groups outside of the .Net parent groups

they currently piggyback, and Kentico

certifications become a sought after

resume item.

There’s a lot happening behind the

scenes to spur it all on, but the reality is

that if a community isn’t already look-

ing for a voice, then providing it with the

tools can’t make things happen.

Having spoken to and worked with

several different groups over the last

couple of months, it’s obvious that the

same pressure points are cropping up

everywhere.

What’s also obvious is that partners

are beginning to get together to discuss

their reactions to these pain points, and

although this is happening on a small

scale and typically beind fairly closed

doors, the powers that be are opening

up to the idea that a shared approach

that works is better than internal IP that

doesn’t.

The next couple of months should

be pivotal, and I’m looking forward to

getting in amongst it all.

Richard Pendergast

Editor

MY DESK

Richard [email protected]@kenticodeveloper.com

Page 7: Kentico Developer Issue 4
Page 8: Kentico Developer Issue 4

RichaRd PendeRgast

Over the last 10 years or so Richard has worked primarily as a Solutions Architect,

delivering solutions based upon various ERP, SCM, CRM, and CMS platforms. He

now works with various teams delivering Kentico based solutions, and has been in-

strumental in the delivery of roughly 100 Kentico based websites and applications.

candice PendeRgast

A journalist by trade, Candice set up her own business a couple of years ago providing

full service marketing to small businesses, delivering any online components using

Kentico. As Features Editor of Kentico Developer, Candice brings together both her

journalism experience and Kentico knowledge to deliver topical pieces and human

interest pieces.

RalPh sPandl

Ralph Spandl is the founder of r42, one of the original founders of Quattrocento, and

has been arcitecting web based solutions longer than most of us have known about

the web. Ralph regularly contributes to the Kentico Marketplace, and writes about his

work within Kentico Developer.

Contributors

Page 9: Kentico Developer Issue 4

Matthew lee

Matthew Lee is one of the key developers behind the 70 or so sites built by Reed

Business Information Australia on the Kentico platform. The development and roll-

out of this enterprise delivery is what allows Matt to speak from experience when put-

ting together his monthly compilation of Tips and Tricks.

thoMas Robbins

Prior to his current role as Kentico product evangelist Thom spent 10 years with

Microsoft, and was one of the key persons behind the success of Microsoft .NET

Framework and Visual Studio. He now produces regular blog posts, video tutorials,

and commentary for Kentico. We are very excited to have him on board.

MaRtijn schifeRli

Several years of developing with Kentico, and a tonne of Kentico sites under his belt,

see Martijn Schiferli bringing a wealth of experience to Kentico Developer. Martijn’s

current passion is the automation of common Kentico tasks using Powersell scripting,

and it’s something we’ll be tapping into quite regularly.

jeRoen fuRst

with over 3 years working with Kentico, more than 50 sites under his belt, and devel-

opment experience with versions 2.0b through 5.0 Jeroen Furst is a vocal member of

the Kentico community hosting his own blog dedicated entirely to Kentico, and in this

issue sharing his thoughts on Kentico 5.0.

Page 10: Kentico Developer Issue 4

uPgRade Package fRoM 4.1 to 5.0 Released

The last weekend of January saw the re-

lease of an upgrade package allowing

sites already hosted on 4.1 to be migrated

to 5.0.

The last real stumbling block for

partners hosting sites on 4.1 and hold-

ing off migrating to 5.0 has now been

removed, and I look forward to seeing

a wide range of upgrades over the next

month or so.

No major issues have been report-

ed with the upgrade package as yet, but

as usual, you’ll find any issues discussed

within the devnet forums, any fixes

documented within the bugtracker, and

can get assistance directly via the regular

support channels.

Ȗ Upgrade package from 4.1 to 5.0

released

http://bit.ly/cRMC7c

the kentico MVP awaRd

Innovative people that partici-

pate and contribute their time, ideas

and resources are the cornerstone of the

worldwide CMS and .NET communities.

This spirit has played an important

role in the growth of the industry as a

whole, and Kentico wants to help foster

this type of community spirit.

The Kentico MVP Award is

designed to recognize individuals already

listening to the community and actively

advocating for Kentico.

The first Kentico MVP award is

scheduled to be announced in early

February based on self-nominations

received by January 31, 2010.

The Kentico MVP Award will be a

one year industry recognition given to

individuals based on their community

participation and evangelistic activities

in the CMS and .NET communities.

The Kentico MVP award does not

include any direct financial compensa-

tion, but will come with

• a 1 Web Site Ultimate License

(value $4,499) for personal or

business use

• recognition on the Kentico

DevNet web site

• participation at selected indus-

try events at Kentico expense

• exclusive access to all Beta

programs

News

Page 11: Kentico Developer Issue 4

• exclusive access to the Kentico

product group

• exclusive special offers that can

be passed on to friends, and

• exclusive promotional packages

sent to all Kentico MVP’s twice

a year.

A Kentico MVP is awarded for one year

and n no more than a total of five awards

will be made during the calendar year

2010.

Ȗ Announcing the Kentico MVP

Award

http://bit.ly/964yKB

blog Post windows liVe wRiteR integRation

When your passion is in spreading word

over the internet, you probably find a

great potential in contributing to vari-

ous blogging sites like Blogger.com or

Thoughts.com.

Working on your post using

browser-based blog interface, you may

sooner or later face an unpleasant situa-

tion when something goes wrong down

the road. If you lose connection while a

post is being published or your browser

crashes accidently, hundreds of lines of

your thoughts disappear and you cannot

get them back.

That is where the desktop blog-

publishing tool comes in handy. One

of my favorites is Windows Live Writer

(http://download.live.com/writer). It is

completely free.

Karol Jarkovsky of Kentico shows

what you can do wen you integrate

Windows Live Writer into Kentico.

This, his first post on the subject

provides an overview and is more about

demonstrating the user experience;, but

Karol has promised to cover all integra-

tion details later as well.

The Windows Live Writer package

has been uploaded to the MarketPlace

and is available for free download. This

is one download well worth getting your

hands on, and one post is well worth the

read..

Ȗ Windows Live Writer

integration

http://bit.ly/a1XcOn

Ȗ Download the package from the

Kentico marketplace

http://bit.ly/b09QTd

fiRst kentico ceRtified tRaineRs

The first ever train-the-trainer course

hosted by Kentico was run in Connecticut

during the last week of February.

Thirteen Kentico partners partici-

pated, and each now carries the title of

Kentico Certified Trainer.

Having not been part of the train-

ing I cannot speak about it from first per-

son perspective, but I am in the process

of contacting several of the participants,

and will write a piece on it as soon as I

know more.

Ȗ First Kentico Certified Trainers

http://bit.ly/c3VKty

blog Post naVigating the kentico cMs web PRoject

Spend a lot of time searching through

code? Trying to find the definition of a

class or enumeration can be difficult.

The Class View window is a han-

dy tool that gives a quick overview of

the object model of the current solu-

tion and allows fast navigation through

namespaces, classes and methods.

Using the Class View window in

conjunction with the Code Definition

window provides a method that can help

to reduce the amount of searching that

needs to be done.

If you double click on a method in

the Class View window, Visual Studio

will open the appropriate source code file

and scroll to the selected method.

This is quite useful for larger proj-

ects like Kentico that contains multiple

class definitions.

See the technique at work in one of

the latest blog posts by Thom Robiins.

Ȗ Navigating the Kentico CMS

Web Project

http://bit.ly/9U1oMa

oPtiMization tiP wRite betteR code disable outPut filteR

Output filters are handlers bound to the

output stream and able to change the fi-

nal HTML just prior to distribution

Kentico provides several output

filters, and uses these primarily in order

News 11

Page 12: Kentico Developer Issue 4

to fix human errors, making the output

HTML or XHTML more valid.

This is great when you have users

working within the source of editable

regions, and entering invalid, or other-

wise damaging HTML.

However, when you are able to con-

trol the quality of your output, the over-

head of the output filters is something

you’ll want to seriously look at removing.

Martin Hejtmanek of Kentico esti-

mates that somewhere in the vicinity of

20% of the load generated when build-

ing a page can be attributed to a global

XHTML output filter.

It’s well worth reading his post

explaining the output filters, the rea-

soning behind them, and the process

required to remove them if you’re that

way inclined.

He concludes the post with “It is a

good thing to have it disabled and write

better code”, and while this may not be as

black and white as it first appears, a 20%

improvement in performance is some-

thing worth investiggating.

Ȗ Write better code, disable

Output filter

http://bit.ly/cvhrQH

new tRansaction ManageMent in 5.0

Within Kentico 4.1, if you wanted to use

transactions, you had to ensure that all

methods within a transaction were given

the same connection object.

Aside from the obvious complica-

tions this brings up, and apart from the

fact that the Kentico transaction han-

dling was not compatible with the .net

TransactionScope class, some parts of

the Kentico API did not even provide a

mechanism for doing this.

Kentico 5.0 now comes with two

new classes, CMSConnectionScope,

and CMSTransactionScope, both of

which are easy to use, and even easier to

understand.

In his latest blog post, Martin

Hejtmanek runs us through the ins

and outs of transaction management in

Kentico 5,0, demonstrating how to make

use of the new classes, and explaining

some of the hidden complexities now

automatically taken care of.

Ȗ Deep dive - New transaction

management in 5.0

http://bit.ly/bhJKGB

MVc and kentico cMs

Martin Hejtmanek kicked off some fairly

animated discussion when he posted an

FAQ piece in an effort to answer part-

ner and client questions about whether

Kentico CMS supports MVC or not.

This is one I made a conscious effort

not to buy into, as I was very interested in

the dialog that was triggered both online

and offline, and didnt want to taint it

with my own opinions and experiences.

Sometimes it’s not so much about

what is written, but about what is not

written, and about what follows after it is

written.

I haven’t seen so much discussion

on a single post since the release of the

Kentico 5.0 pricing, and welcome the

commentary.

Hats off to Martin for attempting

to address an issue that really is front of

mind for a lot of people at the moment.

It’s not easy to stand up and make a state-

ment about something that people are so

passionate about, knowing that you will

most likely be flamed.

Hats off to though to the partners

and clients who bought into the discus-

sion, pointing out oversights on one

hand and then demonstrating where

Kentico fits in on the other.

I hope much of the discussion was

taken on board and that something valu-

able comes from this.

Definitely a worthwhile read.

Ȗ MVC and Kentico CMS

http://bit.ly/aESVYe

toP 10 websites foR deceMbeR

From 174 partner submissions, Petr

Passinger of Kentico selected his top 10

for the month of December, and while

I would have liked to have seen a small

writeup on each, the sites are worth

checking out as a demonstration of

the high quality work being done with

Kentico.

I did notice that some of the more

controversial sites mentioned on Twitter

didn’t make the list, but the list is a good

one, and althoug I have not yet seen a

similar post for February I hope Petr gets

in and posts again.

Check it out if you’re looking for

12 News

Page 13: Kentico Developer Issue 4

examples of really interesting work.

Ȗ Top 10 websites for December

http://bit.ly/9taYf3

jeRoen fuRst

An interesting blog to appear on the

scene recently is that of Jeroen Furst.

After a quick read, I found his writ-

ing interesting enough that we contacted

him directly, asking to include one of his

posts in this issue of Kentico Developer

magazine.

This will be one to watch I think,

and I look forward to reading future

material.

Ȗ blogs.jeroenfurst.nl

http://bit.ly/cfBPjC

webinaRs and Videos

Everywhere I turn lately there seems to

be a new Kentico webinar series taking

off, or a new video tutorial series gain-

ing traction, and the quality of the mate-

rial is surprisingly really, really good on

average.

Where it used to be that I’d struggle

to find anything worth mentioning, there

is now so much good stuff that I struggle

to filter it down to a list of honourable

mentions.

Check out the list below. I’ve

included all of the up and coming webi-

nars I could find, and packaged them

together with anything else that’s come

out over the last month or so that I feel is

worth looking at.

It’s a long list, but honestly, at this

rate I’ll be very surprised if I cant create

one just as long next issue.

Ȗ Online User Group

Martin’s Top 5 for Version 5

(Webinar - January 19)

http://bit.ly/aczk8c

Ȗ Introduction to UI

Personalization

(Webinar - February 4)

http://bit.ly/d7bPC7

Ȗ CMS Today

Generate Buzz, Leads, and Sales

Using a CMS

(Webinar - February 9)

http://bit.ly/bNBUeo

Ȗ Technical Learning

New Features in Version 5.0

(Webinar - February 18)

http://bit.ly/bg0rzV

Ȗ CMS Today

Knowing When You Need a

CMS

(Webinar - February 25)

http://bit.ly/aH7WqI

Ȗ CMS Today

Driving Success with SEO

(Webinar - March 9)

http://bit.ly/9KAJ0n

Ȗ Technical Learning

Introduction to Widgets

(Webinar - March 16)

http://bit.ly/dzKqnd

Ȗ Macros in Kentico CMS

http://bit.ly/aBn38j

Ȗ Version Comparison Using

Workflow

http://bit.ly/dDh54V

Ȗ The WYSIWYG Editor

http://bit.ly/9ifI02

Ȗ Defining a Workflow

http://bit.ly/aSef20

Ȗ Company Details Pages

http://bit.ly/9H0Q57

Ȗ Defining a New E-Commerce

Product Type

http://bit.ly/aRoc1z

Ȗ CSS Menu Design

http://bit.ly/boGd0S

Ȗ Sorting and Paging with the

Product Datalist

http://bit.ly/9DKSSN

Ȗ Adding E-Commerce Products

to Multiple Categories

http://bit.ly/bPIuXi

Ȗ Customizing E-Commerce

Product Categories

http://bit.ly/9jCoEL

Ȗ E-Commerce Featured Products

http://bit.ly/aDHIV5

Ȗ Adding Product Options

http://bit.ly/dmCNY8

Ȗ Adding a New E-Commerce

Product

http://bit.ly/bNzBVZ

Ȗ Sample E-Commerce Purchase

http://bit.ly/aja9Fi

Ȗ Using the New Site Wizard

http://bit.ly/c5PmRu

Ȗ Widget Overview

http://bit.ly/8kFfZ8

Ȗ UI Elements Overview

http://bit.ly/65rKJL

Ȗ UI Personalization

http://bit.ly/6sxqYb

News 13

Page 14: Kentico Developer Issue 4

The key thing which makes Powershell different is that unlike

most shells, which accept and return text, PowerShell is built

on top of the .NET Framework, and accepts and returns .NET

Framework objects. Just imagine being able to pass around

native .net objects, and being able to call methods and access

properties on those objects, directly from the command line.

The basic unit of work within PowerShell is the cmdlet

(pronounced “command-let”), a simple, single-function com-

mand-line tool built into the shell. PowerShell includes more

than one hundred of these cmdlets, giving you access to not

only the file system, but to complex stores such as the registry,

the IIS metabase, and digital signature certificate stores.

Over the next few issues of Kentico Developer, we will be

demonstrating how you can easily expose Kentico API func-

tionality via Powershell, by rolling your own re-usable library

of Cmdlets, allowing for the command line management and

automation of Kentico.

getting staRted

In order to develop your own Powershell Cmdlets you’ll need

to install the Windows SDK. You won’t need to do this if you

are simply looking at using Powershell, only if you are look-

ing at developing your own cmdlets. Don’t worry, the process

Command line Kentico

Unless you’re in the habit of writing little command line applications, Kentico appears at first to be difficult to automate, and nearly impossible to manage from the command line. At least, that was the case until the introduction of PowerShell, a dynamic language from Microsoft which allows you to script admin tasks that previously would have required VB, VBScript, or C#. Think of Powershell as a DOS prompt on steroids.

Page 15: Kentico Developer Issue 4

is relatively painless. Various flavours of the SDK can be found

at http://msdn.microsoft.com/en-us/windowsserver/bb980924.

aspx

You’ll also need Visual Studio and access to a Kentico

database to work with while debugging.

We run Visual Studio Express Editions (Visual Studio

SQL Server 2008 Express and Visual Studio C# 2008 Express)

which are freely available, and this works well if you’re looking

for a basic setup for the very cool price of free.

Downloads of Visual Studio Express Editions can be

found at http://www.microsoft.com/exPress/

setting uP the PRoject

OK, so let’s get into it. First, you’ll need to create a new Class

Library within Visual Studio named KenticoCmdlets.

Next you’ll need to add several required references.

A Powershell Cmdlet will require both System.Management.

Automation and System.Configuration.Install.

You’ll need to browse to find System.Management.Automation.

It comes with the Windows SDK and should be found under

%programfiles%\Reference Assemblies\Microsoft\Windows

Powershell\v1.0

You’ll find System.Configuration.Install registered as a

.net library.

Pulling in the kentico aPi

For Powershell to be able to work with the Kentico API, you’ll

need to add references to the Kentico DLLs. I find the best way

to do this is to browse to a local installation of Kentico. This will

mean that right from the start, your Powershell Cmdlets will be

using the same version of the DLLs that your site is using.

You can either selectively add the DLLs you know you’ll

need, or if you’re just getting started and don’t yet know your

way around the Kentico API, adding anything beginning with

CMS is a safe bet.

YouR fiRst cMdlet

Now that we’ve set up the project we can begin coding our first

Cmdlet.

Add a new Class named GetSites to your project, and

import the classes that you know you’ll need right off the bat –

you can add more as you go. The image below highlights the set

I typically begin with.

CommaNd LiNe KeNtiCo 15

Page 16: Kentico Developer Issue 4

The next piece is important, as this is where I find most people

come unstuck. Declare the Class GetSites as public, and inherit

from Cmdlet. It sounds simple I know, but if things go awry,

come back and check this before digging further.

Next we add code to the Cmdlet, by simply overriding

ProcessRecord(). If you let intellisense fill in the blanks, it’ll

prepare the code for you.

Insert your code – in this case, we’re simply calling the API

function SiteInfoProvider.GetAllSites().

Notice that I’ve added a line of code though which pro-

gramatically sets the database connection string. If you’re

already working with Kentico, you’ll know that this is some-

thing you’d expect to find within a web.config file, or an app.

config. I’ve added this because although I’m not going to do it

now, I’ll add a parameter to the Cmdlet in future, which will

allow you to pass a connection string from the command line.

Set the connection string to the same connection string you use

in your web.config.

Finally, add the Cmdlet attribute to the GetSites class, and

we’re done.

That’s it! This is now a complete Cmdlet. The next pieces are all

about packaging finished Cmdlets for distribution, and config-

uring your debugging environment.

adding a snaPin

Think of a snapin as an installer, used to package Cmdlets for

distribution. We’ll add one now by simply adding another class

to the project.

In this case we will be adding a snapin for our one and

only Cmdlet, but it is possible to add several related Cmdlets

within a single snapin, allowing an end user to add several

Cmdlets to Powershell with a single import.

16 CommaNd LiNe KeNtiCo

Page 17: Kentico Developer Issue 4

installing the class libRaRY

You should now be able to build your class library with no er-

rors, so that it can be installed and registered with Powershell.

A Cmdlet class library is installed using InstallUtil, which

you can tap into easily by starting the command shell you’ll find

installed with the Windows SDK. There’s nothing funky about

this command shell apart from the fact that the tools that come

with the SDK are already included in the path and you won’t

have to browse for them.

Windows 7 users should take note of the fact that the

command shell will need to be executed in the context of an

administrator so that it has the necessary permissions to make

changes to your system. You can do this by right clicking on the

command shell menu item and selecting Run as Administrator.

From within the command shell, navigate to the directory

that your class library compiled to, and install it by invoking

install –I as shown below.

Now, open Powershell – you’ll find it in the Start menus un-

der Accessories – and check that your Cmdlets successfully

installed by using the get-pssnapin Cmdlet with –registered

as a parameter. This lists all installed libraries. You should see

KenticoCmdlets listed.

configuRing the debuggeR

From within the Powershell session you still have open, import

the snapin we created, by invoking the add-pssnapin Cmdlet

with GetSites as a parameter.

What you’ve just done, is pull in any Cmdlets associated

CommaNd LiNe KeNtiCo 17

Page 18: Kentico Developer Issue 4

with the snapin, allowing them to be used form the command

line.

We’re going to cheat a little though. So that you don’t have

to type this every time you kick off the debugger, we’re going

to export the console - an XML file which records imported

snapins. Then, if we tell the debugger to use this console, the

snapins will come pre-loaded.

To export the console, invoke the export-console Cmdlet

passing the path of the file that will be created. Console files are

saved with an extension of psc1.

Now it is simply a matter of telling Visual Studio that when de-

bugging this particular class library we’d like it to use Powershell

as the external application making the calls, and that when it

starts Powershell it should use the console we just exported.

This is done by bringing up the properties of the project

and clicking the debug tab. Select Start external program, and

browse to the Powershell executable. Then enter –PSConsoleFile

<consolefilepath.psc1> in the command line arguments.

There’s a trick to this though, in that Visual Studio Express

Editions do not allow for the invoking of an external program

during debugging. Thankfully, a little hack gets us around this

limitation.

The settings in the debug tab are saved out to a file with

the same name as the project, but with a .user extension. For

example we’d be saving to a file named KenticoCmdlets.csproj.

user. Since Visual Studio will not allow us to do this via the IDE,

we simply have to do it via good old trusty notepad.

If a file with this name already exists, edit it. If it doesn’t,

create it. The contents of the file – as it should appear - appear

below.

debugging

Now, try adding a breakpoint in the code, kicking off a debug

session by hitting f5, and invoking our cmdlet from within the

resulting Powershell by issuing the command get-sites. Check

out the CmdletAttribute if you’re wondering why the command

is get-sites.

Once you’ve confirmed that the breakpoint is hit, let it run, and

take a look at the output.

What you’re seeing is a DataSet, the results of the Kentico

API function SiteInfoProvider.GetAllSites(). The cool thing is

that because we are using Powershell, and because Powershell

works with objects, we can work with the DataSet directly as

shown below.

18 CommaNd LiNe KeNtiCo

Page 19: Kentico Developer Issue 4

neatening uP YouR Results

However, an alternative way of doing things is to return Kentico

SiteInfo objects, rather than rows of data, making the results

easier to work with. Try exiting the debugging session, making

the changes below, and once again hitting f5 to start debugging.

What you’ll find now is that you can use the following syntax

which is much cleaner, easier to read, and a hell of a lot easier

to write. More importantly, once you have further Cmdlets you

can begin to pass the objects between these Cmdlets.

next stePs

It’s simple to begin tacking on more and more Cmdlets, adding

more and more capabilities. Although each Cmdlet does very

little by itself, it’s the piping capabilities of Powershell which

make them so powerful.

For example, the Cmdlet we have just put together enu-

merates sites, returning an array of SiteInfo objects. If we were

to create a simple stop-site Cmdlet and a start-site Cmdlet, we

would be able to restart all of our sites using the following.

get-sites | foreach-object { stop-site $- start-site $_ }

Over the next few issues of Kentico Developer, we will be build-

ing upon what is in essence just a simple demonstration, expos-

ing more and more of the Kentico API within Powershell, and

building up more and more complex examples.

We’ll also be adding parameters to all Cmdlets, something

I really wanted to include here, but that we left out due to a lcak

of space and in the interests of simplicity.

The resulting class library will be made available on the

Kentico marketplace, and I hope that with the input and feed-

back we receive we will be able to make it a very worthwhile

management toolset.

fuRtheR Reading

Ȗ Powershell Syntax, Tutorials, and Guidelines

http://www.computerperformance.co.uk/powershell/

index.htm

Ȗ Windows SDK

http://msdn.microsoft.com/en-us/windowsserver/

bb980924.aspx

Ȗ MSDN – Windows Powershell

http://msdn.microsoft.com/en-us/library/

dd835506(VS.85).aspx

Ȗ Windows PowerShell Blog

http://blogs.msdn.com/PowerShell/

CommaNd LiNe KeNtiCo 19

Page 20: Kentico Developer Issue 4

Thom joined Kentico late last year as a Product Evangelist,

and already we are seeing formal training and certifications

appearing, regular webcasts and instructional videos being

made available, new discussions surrounding best practice kick-

ing off, and Kentico beginning to speak of an enterprise solu-

tion with good reason and the material to back up the claim.

Much of this comes as a direct result of Thom, and of the

depth of experience he brings with him.

With a career at microsoft spanning somewhere in the

vicinity of 10 years, Thom started out in developer platform

evangelism as one of the very first Microsoft evangelists, even-

tually moving to corporate eveangelism where he was respon-

sible for various elements of visual studio.

The move to Kentico was prompted by both changes with-

in Microsoft, and a desire to get a bit more hands and make

change personally.

“Microsoft is a fascinating company with so many cool

technologies but it’s easy to become complacent when youre

dealing with product releases that are so far away.

When I left we were dealing with visual studio 12, which

is due out in 5 years. I wanted to see the impacts of what I was

doing hit the market, and I wanted to see them a little bit quick-

er than 5 years from now.

Kentico is an opportunity for me to reconnect with my

On Not Boiling the Ocean

Introducing our latest contributors allows me to also introduce at the same time one of the biggest things to happen to Kentico within the last couple of years - Thom Robbins. Since leaving Microsoft and moving to Kentico, Thom has been making waves in the Kentico community, doing all of the things I’d hoped to do when I started the magazine, but doing them well, full-time, from the inside, and with full Kentico backing.

Page 21: Kentico Developer Issue 4

roots and to do things that I can see the results of right away.

As a senior director with Microsoft I tended to run large

groups, which kind of separated me from my core element, my

core audience, and I really wanted to get back to the technology.

I wanted to be able to do things, It was fascinating for me to be

able to install visual studio, and show stuff off, and do stuff. It

was fanatastic and fun.”

Thom sees the role of Product Evangelist as one of

education.

“People don’t always know what a CMS is, or why they’d

want one. And take Version 5.0, people don’t yet know what

widgets are, they don’t know about UI personalisation. An

evangelist builds awareness, answers questions, presents new

features and disusses the roadmap... you know, spreading the

love. That’s what an evangelist to me is really all about.”

But it’s also about making sure that, as he puts it, “cus-

tomer voices are carried.”

“Ive already been interviewing and working with custom-

ers, drawing feedback, and preparing what will be actioned in

5.5. You’re going to see a lot of that coming through. One of the

things that really attracted me to kentico was that I was seeing

a small company that was willing to listen, and that was really

willing to action things, and that’s kind of very unusual.

Peter is an amazing visionary with an ability to make

things happen. We talked a really long time before I made the

decision to come over to kentico. He and the company as a

whole are impressive in that their system functions and they

really are getting stuff done. What they hear is being actioned.

He also really cares about customers and that’s the thing

I was most interested in, that in good times or bad he’d want to

continue caring about his customers and wanna continue doing

the right things.

The fact that kentico is a worldwide company means that

its super important when thinking of how to scale, we realise

that we have to scale through partners. And petr does a great

job of making sure we do the right thing by our partners, that

we’re always listening to what they’re saying.

I was just coming aboard when petr was going through

the Version 5.0 pricing, and it was impressive in the sense that

he really listened. There was a lot of discussion about the best

thing to do. Im always impressed when any company listens

and is willing to make changes based on what they hear.

I mean like anyone we’ve got revenue targets and we wan-

na hit them, but at the same time we have to do whats right by

our partners and our customers, or we won’t grow.”

But it’s the education side of things where Thom is really

making waves right now. You only have to take a look at Kentico

DevNet to see that 4 out of 5 posts are put together by Thom -

instructional videos, white papers, and discussion pieces. He’s

like some sort of crazy publishing machine.

“Well, I have to keep moving. I have to get this stuff out

there. There’s so much that people are still looking for. At the

same time, I don’t wanna boil the ocean. I’m aware of the fact

that I can’t do everything right now. I wanna provide some basic

materials at first and work up to the more difficult stuff.

You know, something I love to hear is a partner telling me

they don’t have enough about X, because I’m like, OK lets go

and write some stuff about X.

I’m answering a need right away, and at the same time

building the foundations for the rest of it.

Right now we’re identifying customers that will enable us

to find out what people are using and how and why, you know,

what their needs are, how the bigger partners are working, what

the key enterprisey tools are. I think a lot of this is going to

come from the partners. These are the guys already using it and

getting things done.

Then its gotta get written so we can validate it - Are people

doing this? Are there better ways of doing it? - and then we’ll

eventually try to validate it in a lab or directly with a customer.

I’m a big fan of grey papers – you write it, and then you validate

it.

From a best practices perspective I’m thinking in terms of

a developer. How do I handle a large team environment, source

code management, development? How do I handle continuous

builds? How do I stay agile? The list goes on.

Im probably going to use a lot of it for the magazine.

It’s a great forcing function pushing me to get a lot of it done.

Something im really kicking around is whether we go down the

oN Not BoiLiNg the oCeaN 21

Page 22: Kentico Developer Issue 4

Prestrictive Architecture Guidance (PAG) path, which basically

means we go into a lab, we build out a team system, we tear it

down, and we build it up again, figuring out what we need to do

along the way. It’s kind of a very detailed, very prescriptive way

of doing things and obviously a much longer path, so I think

the first couple of rounds are going to be about collecting basic

practices, putting them together, and then starting to roll those

out while we move forward from there, putting them into more

effective documentation. Eventually I’d like to have something

up on DevNet around enterprise guidance.

I think that we know enough now that we could make

some PAG that we can roll out in the next couple of months.

With Version 5.0 we did a lot of testing, and its like, how do we

present that testing and performance to the public? How do we

create a set of topics so that when we go out to a large company

who tell us that we can’t handle scalability and that they have

10000000 users, we can point them at guidance documents out-

lining the infrastructure needed to get them going, and demon-

strating that we can actually handle their requirements.

I mean im not a fan of boiling the ocean. I’ll take what we

have and build out the topics. We’re starting to get together with

partners around what they’re currently doing, and then build-

ing up the information that comes back. We’re offering to have

them write white papers, and we’ll see how that goes.”

As our latest contributor, Thom was keen to know what

would work best with our readers.

“A monthly best practice for the mag? OK, do we solicit

questions, like ‘Whats the best practice for change manage-

ment?’ and then cover that for a month or do we write an article

each month and see how it goes? I mean whats the best way to

work with your readers? Do they want questions or answers?”

And honestly, without having had a great deal of criticism

so far, it was difficult to answer.

“I think its worth putting something out there that’s youre

understanding of a given topic at this point - a statement, right

or wrong. Think of it as a grey paper, something set up to solicit

discussion, something to use that as a starting point. Invite com-

mentary, and evolve the topic over time. If you keep the topic

simple, it can be used as a talking point, stimulating discussion

and improvement, which then allows the piece to evolve and

become a white paper.”

Thankfully, this works well with Thom’s idea of the grey

paper, and ties in well with his feelings about boiling the ocean,

so we can look forward to regular writings, heated discussions,

and the beginnings of some really significant guidance docs.

We’ve already discussed a need for large team best prac-

tice - concurrency, version control, testing, management, and

deployment - and the need for breaking these topics down, but

Thom puts it very simply.

“I don’t think youre going to put together an article on

testing. Youre going to put together an article on unit testing.

You keep it small and easy to take on board.

I also think of it in terms of how you should do it and why

you should do it. You know, what is this thing, why would you

do it, and how would you do it? There’s no point understanding

how something is done if you don’t know why you’d do it in the

first place.”

This is great stuff, and I for one am really looking forward

to it.

Thom brings with him a wealth of experience in this

space, the full backing of Kentico, the dedication and passion

of someone with a new toy, and the time that comes with a full-

time role, all of which allow him to do what a lot of us have

been wanting to do for a long time - put together the material

that shows that the Kentico CMS is a solid product and that the

horse that we’ve saddled our ponies to is worth the ride.

And honestly, although it will take time for this all to

come to fruition, I’m glad that we all have a chance to be part of

the process. We all bring something to the table, and although

Kentico build the platform, it’s the partners that use it, so it’s

awesome to see that we’ll be part of the mix.

22 oN Not BoiLiNg the oCeaN

Page 23: Kentico Developer Issue 4

A Kentico 5.0 Single Site Ultimate License

To celebrate the release of Kentico 5.0, you can now have Kentico Developer delivered to your door for the reduced cover price of $15.00 (plus shipping), and what’s more, by becoming a subscriber you could have the chance to win a Kentico CMS 5.0 Single Site Ultimate License valued at $4,499!

Visit http://www.kenticodeveloper.com for details

Subscribe and Win!

Issue 1 Issue 2 Issue 3

Page 24: Kentico Developer Issue 4

all 4 the dRiVeR

I musn’t be part of the target audience for

this one, as I don’t really get it. A really

good looking site with great transitions

and great photography, I really wanted to

like it but found myself wanting more.

The philosophy is great. “It’s an

exciting challenge that has been passion-

ately embraced by every member of the

Subaru family, to ensure that the experi-

ence you receive from the showroom, to

the service counter, to the friendly voice

at the end of the phone are all positive

and memorable ones.“

I was hooked. My last experi-

ence with a car dealership wasn’t all that

great and I was intrigued, but searching

through the site left me unsure how the

promise would be delivered, and what it

would mean for me as a driver.

I love the thinking behind the cam-

paign, but can’t help but feel that a little

more information and depth would have

sold it to me.

Ȗ All 4 the Driver

http://bit.ly/cPMpdl

jaMeson iRish whiskeY

What a great little website. Fluid Rock

have excelled themselves with this one.

I love it.

Considering the fact that I don’t

drink Jameson Whiskey, I honestly didn’t

expect much, but the site surprised me,

and I found it really interesting, and

more importantly, really engaging.

I didn’t add a toast at the World’s

Longest Bar but really felt like I should

after watching the videos of others that

have. This is a great concept, something

I haven’t seen done before, and it works.

How often do you actually sit and watch

commentary left by others? Very cool.

I love the fact that what appears

at first glance to be a flashy promotio-

na site contains so much information

about the product and the brand. I mean

who would have thought that Jameson

Whiskey is gluten free?

Check it out. This is great site beau-

tifully executed.

Ȗ Jameson Irish Whiskey

http://bit.ly/aruZH2

Page 25: Kentico Developer Issue 4

Penthouse geRManY

I have to admit that I found it hard to re-

view this site, and not just because I don’t

speak german. It’s difficult to explain to

your wife that you’re checking out the

german Penthouse website because it will

be good for other Kentico developers.

The site is pretty much what I

would have expected in this instance -

essentially a searchable digital edition

of the printed magazine, with an email

based newsletter tacked on.

What I was surprised about is the

volume of content available on the site.

OK, so there’s no archive of previous edi-

tions, but considering the fact that adult

content is typically marketed via a teaser,

the discovery of most of an issue freely

available online was unexpected.

CSS have put together a site that

really shows off the magazine in it’s best

light, and although this site is definitely

not safe for work (NSFW), it’s worth tak-

ing a look at.

Ȗ Penthouse Germany

http://bit.ly/dkuehr

cuP coffee

I have to say that I’ve never come across

a site with a wood-grained background

that I’ve actually liked, let alone one that

I would call anything but tacky, and yet

somehow The Famous Group have cre-

ated a site for boutique coffee house Cup

Coffee that I would actually call some-

what classy.

The photography of grind-

ing machinery, roasters, and espresso

machines is of a very high quality, and

the focus of each image highlights a

beauty in the coffee making process that

shows a real passion for the entire affair.

Put together with a couple of really

nice fonts, subdued colors that work well

with the brand, and copy that makes the

coffees sound mouthwatering, the result

is a site that makes coffee more interest-

ing than I ever thought it would be, and

Cup Coffee somewhere I would be inter-

ested in visiting.

This is a really really nice little site.

Ȗ Cup Coffee

http://bit.ly/97YFzH

gReat beeR gReat ResPonsibilitY

“We make it a priority to support

our employees and the communities

where we live, work and sell our beer.

After all, without great people brewing

our beer and great communities to enjoy

our beer, we couldn’t exist as a company.”

Now I’m a bit of a cynic, and my

first reaction was to gag at yet another

brand jumping on the green bandwagon,

but after digging around a bit I was sur-

prised. MillerCoors really are involved

in a lot of socially responsible programs,

and not just token programs that get

points on the board and pay homage to

someone else’s ideals.

Fullhouse have done a great job

of pulling together a site that is not only

engaging, but that contains a lot of infor-

mation in a very easy to digest format.

The video introduction draws you in and

the depth of content keeps you digging.

I like it a lot, and rate the use of

actors that don’t come across as drones.

Ȗ Great Beer Great Responsibility

http://bit.ly/9JsF0F

Page 26: Kentico Developer Issue 4

Over time, we’ve worked with many clients, each with their

own requirements, questions, and key pain points which need

addressing within a proposal. So, like any other good agency

out there we developed our own knowledge base, and gradu-

ally pulled together answers to typical questions, giving our

salespeople a set of ready answers for the questions that we’ve

learned typically come up.

This works really well, but takes time and a hell of a lot of

effort to build up, and clients with unique requirements can still

incur heavy research.

This is where the RFP Builder contained within the

Kentico partner portal really begins to shine.

The RFP Builder is essentially a knowledge base, where

you can find typical RFP (Request for Proposal), or ITT

(Invitation to Tender) questions answered.

I haven’t seen it talked up much yet, and I can only guess

that this is because Kentico would like to see a critical mass of

questions and answers before they really begin to push it.

I’d really recommend getting in there now and having

a look around. A glorified FAQ, the RFP Builder already has

enough content that it has had to be broken down into sections,

and you’ll already find answers to questions on topics such as:

• Licensing and Pricing

• Content Editing

FA(Client)Q

When we began working with Kentico way back in 2008, there was very little in the way of sales support, and selling a Kentico solution was very much an artform in itself. The work involved in encountering and learn-ing to answer Frequently Asked Client Questions was almost as important as the work involved in actually getting in and putting together the final solution.

Page 27: Kentico Developer Issue 4

• Documents and Assets

• Workflow Requirements

• Security Requirements

• SEO

• Multi-lingual Support

• Performance and Scalability

• Development, and

• Each of the Kentico Modules

To give you an idea of the content contained within each, I

looked for a couple of extremes.

A question asking a salesperson to “Describe the scalabil-

ity of your product”, had a fairly technical answer of just over

1000 words, with some fairly detailed discussions surrounding

caching.

A question asking a salesperson to “describe what news-

letter features are available in your product”, had a non-techni-

cal aswer of around 250 words describing the newsletter func-

tionality available within Kentico.

Kentico are open to new questions, and posting new ques-

tions will lead to new answers, and a growing knowledge base.

We’re already finding that the early knowledge base we put

together ourselves, is beginning to be dwarfed by what exists in

the partner portal, and more importantly, answers to questions

that we haven’t yet had to answer are appearing, meaning that

we are already prepared when we do.

The information is not static, and apart from the fact that

Kentico make an effort to keep the material up to date, a mecha-

nism is included which allows you to comment on a particular

item, to add further detail, or to extend the question.

This is a great resource, and one I’m not sure that people

really make the most use of just yet, but just in case this is not

enough, there is also another toolset evolving within the part-

ner portal - the Sales Builder - a collection of leaflets, brochures,

presentations, and official partner logos put together to make

selling just that much more easier.

There is not a lot of material contained within the Sales

Builder section of the website just yet, but the Kentico CMS

Brochure is very good, and justifies the section almost entire-

ly on it’s own. Outlining Key Benefits, Key Features, Benefits

for Marketers, Benefits for Developers, and Benefits for Web

Agencies, it’s both a great starting point for proposals, and a

great addition to a proposal folder.

I think the natural progression will be the collection of

data within the RFP Builder, and the putting together and pol-

ishing of popular material within the Sales Builder.

We no longer maintain our own knowledge base, and at

this point are more interested in working with the other part-

ners to flesh out and grow the RFP Builder.

As agencies, we may each have a unique set of proposal

templates that we use, costings that we know and are comfort-

able with, and offerings that we are prepared to take to market,

but it’s good to know that behind the scenes the Kentico partner

portal exists to help answer client questions and requirements

in a self-serve manner without us having to pull in Kentico sales

support staff on every proposal.

You can gain access to the Sales Builder, the RFP Builder,

and various other tools, by registering as a partner via the

Kentico website.

fuRtheR Reading

Ȗ Register as a Partner

http://bit.ly/dnVPOq

Ȗ The Kentico Partner Portal

http://bit.ly/cipl4T

Ȗ RFP Builder

(requires partner login)

http://bit.ly/buceNN

Ȗ Sales Builder

(requires partner login)

http://bit.ly/bQQmS2

Fa(CLieNt)Q 27

Page 28: Kentico Developer Issue 4

Petr pointed out a blog a little while back and I couldn’t help but

sit up and take note. Here was someone who really had their

head around blogging - short sharp interesting timely posts well

illustrated - and who at the same time really seemed to be on the

ball with Kentico.

This piece is typical of what you’ll find on the blog of

Jeroen Furst, and if for nothing else than he blogs so much bet-

ter than I do, I recommend you check it out.

I spoke with Jeroen rcently, and was surprised to discover

a guy with over 3 years working with Kentico, more than 50

sites under his belt, and development experience with versions

2.0b - 5.0.

I mean I only heard about IBL Software for the first

time during the Kentico Site of the Year awards, when the

Machinebouw site took runner up in the manufacturing

category.

This is a group I look forward to seeing more of, and

Jeroen’s is a blog that I will be watching with interst.

Jeroen speaks regularly of wanting to get in touch with the

Kentico community in order to share thoughts about approach-

es, techniques, functionalities etc, and I really do feel that if he

sticks with it we may have a future MVP in our midst.

Have a read of Jeroen’s take on the things in Kentico 5.0

that make life easier, and see what you think.

In what is without doubt the easiest read I’ve yet come across regarding 5.0, Jeroen Furst of IBL Software and blogs.jeroenfurst.nl gives us his take on the new Kentico CMS featureset.

10 things in Kentico 5.0 thatmake life so much easier

Page 29: Kentico Developer Issue 4

1. dRag & dRoP in the content tRee

Do I have to say more? Who hasn’t been

frustrated by the fact that you have to

move something up and down the tree

one step at a time? This is gold.

2. bulk oPeRations

In previous versions of KenticoCMS

it was only possible to delete multiple

documents at the same time. With

Version 5.0 it is now possible to: Move,

Copy, Link, Delete, Publish and Archive

multiple documents with just a couple of

clicks!

3. eVent log coloRing

I like the new layout of the Event Log.

Although it is just a subtle change, the

addition of the colours in the grid make

it a lot more clarifying.

4a. ui PeRsonalization (wYsiwYg editoR)

It is now possible in Version 5.0 to cus-

tomize the WYSIWYG editor on a role-

by-role basis (how cool is that?!)

4b. ui PeRsonalization (Module access)

It is also possible to control the access of

modules on a role basis

5. web PaRt dialog shoRtcuts

A minor improvement but oh so nice

when modifying large web part proper-

ties, it is now possible to jump to a group

within a web part properties dialog.

Page 30: Kentico Developer Issue 4

9. sMaRt seaRch in foRuMs

While the Smart Search functionality

was already added in KenticoCMS 4.1, it

became clear to users that Smart Search

lacked functionality. Version 5.0 adds

“Forums” as index type which is a great

improvement. Hopefully index types like

“Custom Tables” will follow in future

10. useR iMPeRsonation

Global Administrators are able to log in

as a different user with just 1 click. In

my opinion this is a really great function

which will save me a lot of time!

6. Media libRaRY consistencY

In previous versions of Kentico an editor

opening up the insert media dialog was

able to preview pictures using different

views (List, Tiles or Thumbnails), but

the same editor using the Media library

Module could use List view only. Version

5.0 brings us a more consistent use of the

Media library.

7. seaRch/filteR in selection dialogs

When you open up a selection dialog

like the “Add web part”, “Add widget”

or “Select Template” dialogs you can

search the desired “Web Part”, “Widget”

or “Template” pretty fast by entering the

name in the search Box and hitting the

Enter key.

8. side-bY-side docuMent coMPaRison

If you are using Versioning/Workflow

then 5.0 offers side-by-side comparis-

ment of documents. This is a very neat

feature which probably will by loved by

most CMS Editors.

fuRtheR Reading

Ȗ Blogs.JeroenFurst.NL

http://bit.ly/cfBPjC

Ȗ 10 things in KenticoCMS 5.0

that make life so much easier

http://bit.ly/aAjk2Y

Powered by IBL software

Development Consultancy Support Hosting

IBL software

www.ibl-software.nl | [email protected]

ProfessionalKentico Development

Over 3 years of experience in Kentico CMS! Provides a dedicated team of Kentico Experts! Implemented more than 50 websites using Kentico!

Powered by IBL software

Development Consultancy Support Hosting

IBL software

www.ibl-software.nl | [email protected]

ProfessionalKentico Development

Over 3 years of experience in Kentico CMS! Provides a dedicated team of Kentico Experts! Implemented more than 50 websites using Kentico!

Page 31: Kentico Developer Issue 4

Powered by IBL software

Development Consultancy Support Hosting

IBL software

www.ibl-software.nl | [email protected]

ProfessionalKentico Development

Over 3 years of experience in Kentico CMS! Provides a dedicated team of Kentico Experts! Implemented more than 50 websites using Kentico!

Powered by IBL software

Development Consultancy Support Hosting

IBL software

www.ibl-software.nl | [email protected]

ProfessionalKentico Development

Over 3 years of experience in Kentico CMS! Provides a dedicated team of Kentico Experts! Implemented more than 50 websites using Kentico!

Page 32: Kentico Developer Issue 4

Introduced in version 4, the media library has quick-

ly become one of my favourite and most often used tools in

Kentico. Since version 4.1 an editor can easily add QuickTime

movies and Windows Media files. But presently, the default

installation doesn’t support Flash movies nor is it possible to

insert them as an inline control into an editable text area.

Over the past few years, Flash Video has become one of

the most used video formats on the web and many powerful

players have been developed to control their playback on web

sites. My favourite player is called JW Player from a company

Longtail Video. A favourite partly because of its slick look, but

also because it is really stable, easy to use and highly customiz-

able and because its open architecture allows developers to cre-

ate add-ons such as colourful skins and plug-ins; In the long list

of add-ons you can find plug-ins for social media, integration of

Google Analytics or a caption tool.

The JW player has only one major disadvantage; It is a

commercial product and requires you to purchase a license if

you want to use it for commercial projects. This is most likely

the reason, why the JW Player is not included with Kentico.

However, not long after I showed Petr Palas this nice piece of

software, the Developer Guide included some instructions on

how to integrate it within the media libraries. You can almost

copy paste the code from there into your installation to make

JW Player

KenticoCMS version 5.0 has been released for a couple of weeks now and I am really enjoying the new features. That’s why I thought that I should write about some (minor) improvements in 5.0 that make work-ing with the CMS a lot easier! There are probably a lot more improvements worth mentioning but I will cover those the next time. So here goes!

Page 33: Kentico Developer Issue 4

it work (Section 8.24.9 Defining custom media types/Kentico

CMS Dev Guide).

There is however one thing that really bugged me with

the provided code; JW Player gives you the possibility to define

the path to a preview image, but the media library does not give

you the opporatunity to specify such a path. A preview image

does not only come in handy for videos, but gives you also the

possibility to illustrate an audio file.

The simplest thing in the world I thought! Why not just

allow the upload of an image in the preview tab for the media

library item? Well, as it turns out, that is not so trivial. It was

only with the help of my programmer colleague Francois

Charbonneau and a handful of help from Juraj Ondrus and the

Kentico support team I finally managed to get it to work.

But let’s go back to the beginning and put in place all files

required. We need to download a copy of the JW Player and we

need some JavaScript to embed the player. Version 5 of the JW

Player has just been released and you can get a copy here: http://

www.longtailvideo.com/players/jw-flv-player/.

To embed the player into the HTML page I suggest using

the swfobject. The complete download including documenta-

tion can be found on Google Code. (http://code.google.com/p/

swfobject/downloads/list).

Now you need to find a place for these items somewhere

in your Kentico installation. I decided to place them in the

CMSModules folder, where I created a new folder called “FLV-

Player”. But you might also decide to place these files in the

“App_Themes” folder.

You also need to make some changes to your config file

and allow flv file extensions for the media library. For these

steps, please refer to the Developer Guide again.

Now we’re all set and there is only one thing left to do;

Make some changes to the “MediaControl.cs” which can be

found in the “CMSInlineControls” folder. Making changes to

the Kentico installation is usually something I try to prevent at

all cost. Because it means that with each new update, you are

most probably required to apply the changes again. And this

might be once or twice a year. So you better carefully document

what you are doing now.

Open CMSInlineControls/MediaControl.cs. You will first

need to edit this part of the file.

This modification tells the media control to what to do with me-

dia file type flv and also mp3 (or any other media file type you

want to be handled by the JW Player).

And then add two functions:

Page 34: Kentico Developer Issue 4

The first function will make it possible to insert the flv or mp3

files and comes with some small modifications straight from the

Kentico example.

The second function will return the preview file from your

media library item. This is actually the part where I suspend my

understanding and start going on faith. But trust me, it works!

Save the file and return to your cmsdesk, navigate to your

media library and upload a flv file and/or an mp3 file. In the

preview box you should now upload an image that will serve

you as the initial still frame that is displayed until the video

starts playing, or alternately, the image that is displayed while

the mp3 sound file is playing.

Once this is done, return to your content section and insert the

flv/mp3 file with the insert/edit media or image button. You will

now see that the JW player is shown in the preview window.

Press insert. As with other media inserted with the media li-

brary inline controls, you will only see this icon in the FCK

Editor window.

Once you preview your page though, you can see that you can

now playback your video or sound file with the JW player while

the preview image is displayed.

I am pretty sure that this function will be appreciated by many

editors that have mp3 files available, but who were until now,

unable to insert them into their pages with a convenient one

click solution.

fuRtheR Reading

Ȗ The r42 blog

http://bit.ly/d5m3IX

Page 35: Kentico Developer Issue 4
Page 36: Kentico Developer Issue 4

If you’re like me you like to get under the

hood every now and then and find out

just ow things tick, and on the odd oc-

casion that you don’t break something

down there you may end up finding

something quite uesful.

The out of the box Kentico SQL

Server views are a great example of this.

Sometimes you want to query the

Kentico CMS content tree directly, rather

than via the website UI, and occasionally

you want answers to questions that the

website UI is not able to provide.

The views Kentico provide are pret-

ty straightforward to use, once you know

they exist, and you don’t actually need to

know all that much to make use of them.

View_cMs_tRee_joined

The view View_CMS_Tree_Joined pro-

vides insight into every document con-

tained within the Kentico content tree

- root documents, folders, blogs, articles,

files etc.

oVeRall docuMent count

Want to know how many documents you

have overall within a particular site? Try

the following.

SELECT COUNT(*) FROM View_CMS_Tree_Joined WHERE SiteName = ‘SomeSiteName‘

docuMent tYPe sPecific count

Want to know how many documents of

a specific document type are contained

within a particular website? Try the

following.

SELECT COUNT(*) FROM View_CMS_Tree_Joined WHERE SiteName = ‘SomeSiteName‘ and ClassName = ‘SomeClassName’

PaRent child RelationshiPs

So far we’ve just scratched the surface

though. What about if we want to find

how many documents exist beneath a

particular path. For this we need to tap

into the parent child relationships of

nodes within the tree.

Every document node within the

Kentico content tree contains a unique

NodeID. Documents with a parent (ie.

documents that exist beneath another

document within the tree) also contain a

Tips and Tricks

Matthew [email protected]@kenticodeveloper.com

Page 37: Kentico Developer Issue 4

NodeParentID.

This information can be used to put

complex queries together very easily.

For example, the following query

answers the question, how many docu-

ments exist beneath a certain path.

SELECT COUNT(*) FROM View_CMS_Tree_Joined Parent join View_CMS_Tree_Joined Child on Child.NodeParentID = Parent.NodeID WHERE Parent.NodeAliasPath = ‘/Some/Path’

Want to make things a little more inter-

esting? How about if we wanted to find

out how many files exist directly beneath

a parent folder.

SELECT COUNT(*) FROM View_CMS_Tree_Joined Parent join View_CMS_Tree_Joined Child on Child.NodeParentID = Parent.NodeID WHERE Parent.ClassName = ‘CMS.Folder’ and Child.ClassName = ‘CMS.File’

custoM docuMent tYPe Views

OK. So, nothing mind blowing yet.

Where things begin to get interesting is

when you understand that for any cus-

tom document type, Kentico provides

ready made views to work with.

For example, let’s say we’ve created

a document type for storing book infor-

mation which we named custom.book,

and a document type for storing chapter

information named custom.chapter.

Kentico automatically creates two

views for us:

View_Custom_Book_Joined View_Custom_Chapter_Joined

These two views work in exactly the

same way as the tree view, and actually

contain the same fields as the tree view.

They do however also contain any extra

fields defined by the custom document

type. making it possible to write complex

queries easily.

Let’s say for example, that for some

obscure reason we want to list all of our

books, ordered by the number of chap-

ters each contains, with the biggest first.

The views listed earlier make this

possible, but fiddly. The custom views

Kentico creates for us make this easy.

SELECT Book.BookName, COUNT(*) from View_Custom_Book_Joined Book join View_Custom_Chapter_Joined Chapter on Chapter.NodeParentID = Book.NodeID group by Book.BookName order by COUNT(*) desc

Note that I’ve used the field BookName,

which is a custom field defined when I

created the custom document type book.

Although this field is not a standard

Kentico field, I can access it directly via

the new views without having to join

anything else in.

So basically, we’ve taken the tech-

nique we used earlier and simply used

the new views rather than the tree view.

The result is that we are able to join

chapters to books directly via the parent

child relationship.

a coMPlex exaMPle

Let’s now try something a little closer to

home. This example is not code that I’d

recommend, given that there is a web

part that does exactly this, but for dem-

onstration purposes this works well.

We’re going to return the bread-

crumbs for a given tree node.

WITH Hierarchy (NodeParentID, NodeID, Level) AS ( SELECT Tree.NodeParentID, Tree.NodeID, 0 FROM View_CMS_Tree_Joined Tree WHERE NodeParentID = <SomeNodeID> UNION ALL SELECT Tree.NodeParentID, Tree.NodeID, Hierarchy.Level - 1 FROM View_CMS_Tree_Joined Tree JOIN Hierarchy ON Hierarchy.NodeParentID = Tree.NodeID ) SELECT Tree.NodeAliasPath FROM Hierarchy JOIN View_CMS_Tree_Joined Tree ON Tree.NodeID = Hierarchy.NodeID ORDER BY Level

What we’re basically doing is taking ad-

vantage of the hierarchy support that

comes with SQL Server 2005 and 2008,

and writing what is a very typical hierar-

chical query.

The syntax may look daunting, but

essentially all we are doing is beginning

with the tree node we are interested in

and recursively joining in all of it’s par-

ents. The top part of the query (the part

in brackets) defines the hierarchy, and

the bottom part of the query (beginning

with SELECT) defines what you’ll get

back.

If you want to dig into this one a

bit, look up SQL Server CTEs within

Google, or feel free to write to me.

tips aNd triCKs 37

Page 38: Kentico Developer Issue 4

A Kentico 5.0 Single Site Ultimate License

To celebrate the release of Kentico 5.0, you can now have Kentico Developer delivered to your door for the reduced cover price of $15.00 (plus shipping), and what’s more, by becoming a subscriber you could have the chance to win a Kentico CMS 5.0 Single Site Ultimate License valued at $4,499!

Visit http://www.kenticodeveloper.com for details

Subscribe and Win!

Issue 1 Issue 2 Issue 3

Page 39: Kentico Developer Issue 4

At Aviva Solutions we believe that using an agile process determines the success of the projects we do. Being agile helps us react to your changing requirements and create the software you need.

That’s why we incorporate agility in all our projects, whether it’s helping you implement a new software factory, building a new web shop, implement your Intranet or helping you with your business intelligence. And it’s all based on Microsoft software.

So why don’t you contact us and see what we can do for you?

Save on your content management

+ 31(0)6 - 497 819 [email protected]

www.avivasolutions.nlblog.avivasolutions.nl

When we went to look for a content management system for our customers we had two things in mind: it should be flexible for our customers as well as us, and it should be good value for money.

That’s why we like Kentico CMS. And so do our customers. It’s so flexible that we were able to integrateMicrosoft Commerce Server, creating a powerful e-commerce platform. But it’s also so flexible and easy tolearn that we can create a new web site in two weeks.

So why don’t you contact us and see how we can help you save your piggy?

T: + 31(0)6 - 497 819 21E: [email protected]

W: www.avivasolutions.nlW: blog.avivasolutions.nl

Internet & Commerce - Business Intelligence - Information Worker - Application & Software Integration - Customs Solutions & Software Factories

Knowledge. People. Solutions.

advertentie a4.indd 1 21-12-2009 10:51:37

Page 40: Kentico Developer Issue 4