Documentation

PageContentRepository

This is an internal API repository used to get body and summaries for pages. This repository will soon be deprecated in favour of a unified public API. So please keep this in mind when using this repository in your code. 

NOTE: You will need to add the directive to use the namespace in your custom cards, or else you will receive errors. Just add the following:

@using OpenRoad.ThoughtFarmer.Core.Repositories

OpenRoad.ThoughtFarmer.Core.Repositories.PageContentRepository

Methods
Name Return type Description
PageContentRepository(string localizationDefaultCulture, string localizationAvailableCultures) PageContentRepository Constructor to initialize instance. Takes in a string to specify default culture and comma separated string to specify available cultures. See examples below for recommended use.
GetSummary(int contentId) LocalizedSortedList Returns the LocalizedSortedList that comprises the Html summary of the page.
GetBody(int contentId) LocalizedSortedList Returns the LocalizedSortedList that comprises the Html body of the page.
GetSummaryAndBody(int contentId, string requestedCulture) SummaryAndBody Returns the SummaryAndBody (as below) that represents the content for this page for the specified culture.
 

SummaryAndBody

This is a simple convenience class returned by the call GetSummaryAndBody.
Name Type Description
Culture string Returns the string for the culture for this SummaryAndBody.
Summary string Returns the string that comprises the Html summary of the page.
Body string Returns the string that comprises the Html body of the page.
 

Example usage:
@using OpenRoad.ThoughtFarmer.Core.Repositories

@{ // Initialize the repository using the default configuration values var pageContentRepository = new PageContentRepository(this.Model.Context.Config.LocalizationDefaultCulture, this.Model.Context.Config.LocalizationAvailableCultures);

 var page = this.Api.Content.Get(123); // Some other page we want to pull content from

 if(page != null)
 {
      var title = page.Title.Get(this.Model.Context.Culture, this.Model.Context); 
      var body = pageContentRepository.GetBody(page.Node.ContentId).Get(this.Model.Context.Culture, this.Model.Context);

      <div class="tfc-custom-container">
             <h2>@title</h2>
             <div class="tf-content">
                @Raw(body)
             </div>
      </div>
 }

}