Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. /* Transformation Examples */
  2.  
  3. // Ternary example
  4. <%# !string.IsNullOrEmpty((string)Eval("ItemToTest")) ? "True" : "False" %>
  5. <%# !string.IsNullOrEmpty((string)Eval("CatalogLink")) ? "<p>For detailed curriculum and more, please visit the <a href=\"" + Eval("CatalogLink") + "\" target=\"_blank\">Course Catalog entry</a> for this program.</p>" : Eval("CatalogDescription") + "<br /><br /><strong>For detailed curriculum and more please visit the <a onclick=\"_gaq.push(['_trackEvent', 'Link', 'Click' 'Course Catalog Adult Education'])\" target=\"_blank\" href=\"" + Eval("CatalogLink") + "\">Course Catalog entry</a> for this program.</strong><br />" %>
  6.  
  7. // IfEmpty
  8. <%# IfEmpty(Eval("Image"), "", "<img src=\"" + Eval("Image") + "\" class=\"alignright\" alt=\"" + Eval("DocumentName") + "\" />") %>
  9. <%# IfEmpty(Eval("Download"), "", "<a href=\"" + Eval("Download") + "\" class=\"btn icon-download\" target=\"_blank\">Download</a>") %>
  10.  
  11. // Macro Resolver
  12. <a href="<%# CMSContext.ResolveMacros( Eval("URL").ToString() ) %>"><%# Eval("Name") %></a>
  13.  
  14. // Visbility
  15. <p runat="server" Visible='<%# Eval<string>("Name") != "some-value" %>'>
  16.  
  17. <cms:QueryRepeater ID="qrConcentrations" runat="server"
  18. Visible='<%# isCurrentPage(Eval<String>("nodeAlias"))%>'
  19. QueryName="custom.DegreePrograms.GetConcentrationsBySchoolModalityAndCategory"
  20. TransformationName="custom.degreeprograms.concentrations"
  21. OrderBy="v1.DegreeName ASC"
  22. PagerControl-PagerHTMLBefore="<li>"
  23. PagerControl-PagerHTMLAfter="</li>">
  24. </cms:QueryRepeater>
  25.  
  26. /* transformation: check if first record */
  27. <%# DataItemIndex == 0 ? "First record" : "Not first record" %>
  28.  
  29. /* transformation: check if last record */
  30. <%# DataItemIndex == DataRowView.DataView.Count - 1 ? "Last record" : "Not last record" %>
  31.  
  32.  
  33. /* K# Examples */
  34.  
  35. // If statement
  36. {% if (CurrentDocument.RelatedTitlesHeader == "") { "Related Books" } else { CurrentDocument.RelatedTitlesHeader } %}
  37.  
  38. {% if (bizFormField != null) { "<p>$$value:bizFormField$$</p>" } %}
  39.  
  40. // nested if statement
  41. {% if (CMSContext.CurrentDocument.RelativeURL == "~/georgia/rate-quote") { GetResourceString("MHI.RateQuote.Georgia") } else { if (CMSContext.CurrentDocument.RelativeURL == "~/indiana/rate-quote") { GetResourceString("MHI.RateQuote.Indiana") } else { if (CMSContext.CurrentDocument.RelativeURL == "~/oklahoma/rate-quote") { GetResourceString("MHI.RateQuote.Oklahoma") } else { if (CMSContext.CurrentDocument.RelativeURL == "~/south-carolina/rate-quote") { GetResourceString("MHI.RateQuote.SouthCarolina") }}}} #%}
  42.  
  43. /* WebPart Visibility */
  44. // Do NOT show if DocumentName is equal to "Home"
  45. {%DocumentName|(notequals)Home|(truevalue){?param?}%}
  46.  
  47. // Do NOT show if NodeID is equal to "211"
  48. {%NodeID|(notequals)211|(truevalue){?param?}%}
  49.  
  50. // Hide page(s) in the /Landing-Pages directory
  51. {%CMSContext.CurrentDocument.NodeAliasPath|(Contains)Landing-Pages|(not)#%}
  52.  
  53. // Show if DocumentName is equal to "Home"
  54. {%DocumentName|(equals)Home|(truevalue){?param?}%}
  55.  
  56. // Show if path contains
  57. {%Contains(CMSContext.CurrentDocument.NodeAliasPath, "Landing-Pages")#%}
  58.  
  59. // Show if path does not contain
  60. {%!Contains(CMSContext.CurrentDocument.NodeAliasPath, "Landing-Pages")#%}
  61.  
  62. // Visibility based on Wildcard value
  63. {%QueryString["County"] != ""%}
  64.  
  65.  
  66. // Date format
  67. <%# GetDateTime("BlogPostDate", "D") %>
  68.  
  69.  
  70. /* String replace */
  71. // Kentico: Transformation, string replace, tolower
  72. <%# Eval("DocumentName").ToString().Replace(" ", "-").ToLower() %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement