c# - How do you put custom markup in a sitecore sc field? -
i need add custom markup sc:image
field enchance seo. markup not property of field, codebehind, tried this:
slideimage.attributes.add("controltype", "c4image"); slideimage.attributes.add("rel", relstring);
but isn't working, , see nothing in rendered output. there way this?
you can create own class inheriting sitecore.web.ui.webcontrols.image
, override this:
namespace my.assembly.namespace { public class myimage : sitecore.web.ui.webcontrols.image { public virtual string relattribute { get; set; } protected override void populateparameters(sitecore.collections.safedictionary<string> parameters) { base.populateparameters(parameters); if (!string.isnullorempty(relattribute)) { parameters.add("rel", relattribute); } } } }
and register namespace , use myimage
class:
<%@ register tagprefix="my" namespace="my.assembly.namespace" assembly="my.assembly" %> <my:myimage runat="server" relattribute="reltest" field="logo"/>
you can use standard attributes sc:image
on my:myimage
well. code generate img
tag rel <img rel="reltest" src="logo.jpg" ... />
.
you can extend code above support controltype
attribute well.
Comments
Post a Comment