以下の内容はhttps://cheatography.com///gregfinzer/cheat-sheets/crownpeak-output-aspx-example/より取得しました。


Cheatography

Crownpeak Output.aspx Example Cheat Sheet by

Output.aspx example for Crownpeak

Example input.aspx

Input.ShowHeader("Contact Us");
Input.ShowTextBox("Page Title", "page_title");
Input.ShowAcquireImage("Contact Us Logo", "contact_us_logo");
Input.ShowTextBox("Contact Us Logo Alt Text", "contact_us_logo_alt_text");
Input.ShowWysiwyg("Address", "address", ServicesInput.FullWYSIWYG());
Input.ShowTextBox("Customer Service Phone", "customer_service_phone");
Input.ShowTextBox("Email", "email");
Place in Projec­t\T­emp­lat­es­\Som­eTe­mpl­ateName

Example Output­Helper Class

public static class OutputHelper
{
	public static string OutputImage(OutputContext context, Asset asset, string imageAssetName, string altTextAssetName)
	{
		UploadedFile file = asset.UploadedFiles[imageAssetName];

		if (file.IsLoaded)
		{
			Img img = Img.Load(file);

			if (!img.HasError)
				return string.Format("<img src='{0}' width='{1}' height='{2}' alt='{3}' />", file, img.Width, img.Height, asset[altTextAssetName]);
			else if (!context.IsPublishing)
				return string.Format("Error Loading image {0}. Error: {1}", img.ErrorMessage, imageAssetName);
		}

		return string.Empty;
	}

	public static string OutputMailTo(Asset asset, string emailAssetName, string linkText= null)
	{
		if (!string.IsNullOrEmpty(asset[emailAssetName]))
		{
			if (!string.IsNullOrEmpty(linkText))
				return string.Format("<a href='{0}'>{1}</a>", asset[emailAssetName], asset[linkText]);
			else
				return string.Format("<a href='{0}'>{0}</a>", asset[emailAssetName]);
		}

		return string.Empty;
	}
}
Place in Projec­t\L­ibrary

Example Output.aspx

<h1><%= asset["page_title"] %></h1>
<%= OutputHelper.OutputImage(context, asset, "contact_us_logo", "contact_us_logo_alt_text") %>
<p><%= asset["address"] %></p>
<p><%= asset["customer_service_phone"] %></p>
<p><%= OutputHelper.OutputMailTo(asset, "email") %></p>
Place in Projec­t\T­emp­lat­es­\Som­eTe­mpl­ateName

Result

Other Useful Helpers

<% var siteRootPath = Asset.GetSiteRoot(asset).AssetPath.ToString(); %>
<%= ServicesOutput.RenderCSSLink(siteRootPath + "/css/style.css") %>
<%= ServicesOutput.RenderScriptLink(siteRootPath + "/js/util.js") %>
<%= ServicesOutput.RenderHyperLink(asset, "buy_now") %>
 

Comments

No comments yet. Add yours below!

Add a Comment

Related Cheat Sheets

Crownpeak Input Controls Cheat Sheet
Crownpeak Models Cheat Sheet
Crownpeak Input Validation Cheat Sheet

More Cheat Sheets by GregFinzer

Loving Your Neighbor Cheat Sheet
AWS Core Service Options Cheat Sheet
Unity Container Cheat Sheet



以上の内容はhttps://cheatography.com///gregfinzer/cheat-sheets/crownpeak-output-aspx-example/より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14