Loading...
Area: Optimizely CMS
Applies to versions: 10 and higher
Other versions:

Creating a component

Recommended reading 

This topic describes how to create a component in the Episerver user interface.

How it works

You can use the CMS-extended Framework IFrameComponent attribute to create a component. 

The CMS extension of the IFrameComponent has the following additional parameters:

UrlFromUtil Optional. The URL to the source, relative the Utils folder. Used instead of Url property.
UrlFromUi Optional. The URL to the source, relative the UI folder. Used instead of Url property.

Creating MVC component

First you need to add a controller. Controller has to be annotated with an IframeComponent attribute.

[IFrameComponent(Url = "/helloworld", Title = "Hello World Component", Categories = "content")]
public class HelloWorldController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

Then add a Index.cshtml view to the Views/HelloWorld directory:

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>HelloWorld</title>
</head>
<body>
<div>
    <div>Hello World</div>
</div>
</body>
</html>

Related information

Do you find this information helpful? Please log in to provide feedback.

Last updated: Sep 28, 2021

Recommended reading