Reputation: 632
Ok, so I've recently started to learn setting up sites in Umbraco, as a client of mine wishes to have it for their site. Now, in their site, they want to have three types of "actions" which they should be able to add to any of their pages. These actions are really just a line of HTML. The way they wish to add it to the page however, is not to copy/paste a line of code (understandable..,) but rather have a tickbox-area.
The lines of code look like this:
<a class="action people" href="/link/"><span>Testimonials</span></a>
<a class="action rac" href="/link/"><span>Request a Call</span></a>
<a class="action contact" href="/link/"><span>Contact Us</span></a>
In short, the user needs to be able to tick in for example "Testimonials", save and publish to page and have the first line of code appear.
I tried going into Developer > Data Types > Create and defining my own based on a Checkbox list, but that's obviously wrong because there is no where to define a "when user ticks this box, save "this" as HTML and insert it into the page"
Edit:
Below, Marapet gave me the push in the right direction I needed. Instead of using a Razor script as he suggested, since I have no knowledge of Razor whatsoever, I decided to finalize the problem with XSLT, so in order to complete the answer, here's the code for that. (This goes in an xslt file referenced by the macro that Marapet suggested.)
<xsl:choose>
<xsl:when test="$currentPage/actionTestimonials = '1'">CODE HERE</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$currentPage/actionContactUs = '1'">CODE HERE</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$currentPage/actionRequestACall = '1'">CODE HERE</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
Upvotes: 0
Views: 837
Reputation: 56446
If those links will always be displayed in the same place (for example footer, sidebar, ...):
if (Model.MyProperty) { ... }
<umbraco:Macro Alias="MyMacro" runat="server" />
- you can use UI buttons in Umbraco to insert the code.Upvotes: 1