I am trying to implement functions for displaying global data types on a composite site c1.
I understand how the basic functions of the razor work, but they only use local data. I am looking to create a razor function that accesses filters (similar to the DataReferenceFilter, available with visual functions), the global data type that I created for the biography of employees so that I can display this information on several pages throughout the site.
I was able to create a visual function that achieves this, but they do not work very well with the editable style.
This is a function layout using local data entry directly into the function:
@inherits RazorFunction
@functions {
public override string FunctionDescription
{
get { return "A people widget that diaplays a picture, name and small bio of a team member"; }
}
[FunctionParameter(Label = "Name", Help = "Input the persons name here", DefaultValue = "Firstname Lastname")]
public string Name { get; set; }
[FunctionParameter(Label = "Position", Help = "Input the persons position here", DefaultValue = "Manager")]
public string Position { get; set; }
[FunctionParameter(Label = "Qualifications", Help = "Input the persons qualifications here",DefaultValue = "University of Newcastle")]
public string Qualifications { get; set; }
[FunctionParameter(Label = "Bio", Help = "Input the persons biography snippit here", DefaultValue = "Input bio snippit here")]
public string Bio { get; set; }
[FunctionParameter(Label = "Image", Help = "Select the image to be used by this people widget")]
public DataReference<IMediaFile> ImageSource { get; set; }
}
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0">
<head>
</head>
<body>
<div class="peoplebox">
<div class="peopleimg">
<img src="~/media({@ImageSource.Data.Id})" alt="..." />
</div>
<p class="peoplename">@Name</p>
<p><i>@Position</i></p>
<h5>@Qualifications</h5>
<div class="blockquote">
<p>@Bio</p>
</div>
</div>
</body>
</html>
, , .