This site is now out of date, and currently exists here as an archive only.

Mentor Web Blocks is still under development.

Please click here to view the latest version.

API Reference

Mentor Web Blocks has the capabilities to render Razor, Usercontrols, and XSLT which is chosen in the Macro.  Each has it's own interface to get the current page and the current block being rendered.  Below you will find the API / Methods available to you/

Razor

When programming in Razor, the Model is the block that is being rendered.  To get the current page node, see the below available API methods.

Method Description
@WebBlocks.GetCurrentNode()

Returns the current page node.

E.g.

@{

     dynamic currentPage = @WebBlocks.GetCurrentNode();

}

<a href="@currentPage.Url">@currentPage.Name</a>

@WebBlocks.GetNode(int id)

Returns a node based on the id chosen.

@WebBlocks.AddBlockClass(string name)

Adds a class to the block control.

Before: <div>[content to render]<div>

Call: @WebBlocks.AddBlockClass("grid_3");

After: <div class="grid_3">[content to render]</div>

@WebBlocks.RemoveBlockClass(string name) Removes a class from the block control.
@WebBlocks.SetBlockElement(string name)

Changes the block control to be rendered as another element.

Before: <div>[content to render]</div>

Call: @WebBlocks.SetBlockElement("span")

After: <span>[content to render]</span>

@WebBlocks.GetWebResource(string url)

Returns a string response from a uri.

(Hint: Use this helper method to retrieve things like twitter feeds etc)

 

Usercontrol

When creating your usercontrol that will be rendered by Web Blocks, inherit WebBlocksUserControl.  This is located in WebBlocks.BusinessLogic.DLL. This will give you access to two properties. 

Block This is the current Block so that you can access the properties set on the block.  This is a dynamic object so you can reference your properties the same as you would in Razor.  For example, Block.pageTitle
CurrentPage This is the current page node.  This is how you access the properties set on the current page.  This is also a dynamic object, so you can access properties the same as you would in Razor.

 

XSLT

When rendering your block with XSLT, you can access the current page using $currentPage.  This naming convention makes sense for it to be the current page.  To access the block you must reference WebBlocksXslt:GetCurrentBlock().

Share this page:
Subscribe: