Call me crazy but this isn't something too much to ask of a CMS
So, on a page where a document type has a section defined as a RTF section AND there are some links to documents within the Media files.... but some of the links to the files must ONLY be shown if the user is logged in.
How can I hide some of the links when the user is NOT logged in?
I haven't tried it myself, buy why not create a macro that wraps a server control or user control that renders the link only if a member is logged in?
you can then enable this macro for the editor
Your control should be something like:
public class MembersLink : Control { public int MediaId { get; set; } public string Text { get; set; }
protected override void Render(HtmlTextWriter writer) { if (umbraco.cms.businesslogic.member.Member.GetCurrentMember() != null) { Media media = new Media(MediaId);
Thanks everyone for your help.... I guess what I was wondering was can this be done at the Content side of things (within the Ruch Text Editor portion) - On the template side I know this is possible.
@Jeroen: If I use Media Protect - would the link in the Rich Text just not show up? Is that how it works... I can read the material and see..
Call me crazy but this isn't something too much to ask of a CMS
So, on a page where a document type has a section defined as a RTF section AND there are some links to documents within the Media files.... but some of the links to the files must ONLY be shown if the user is logged in.
How can I hide some of the links when the user is NOT logged in?
Allan
I haven't tried it myself, buy why not create a macro that wraps a server control or user control that renders the link only if a member is logged in?
you can then enable this macro for the editor
Your control should be something like:
public class MembersLink : Control
{
public int MediaId { get; set; }
public string Text { get; set; }
protected override void Render(HtmlTextWriter writer)
{
if (umbraco.cms.businesslogic.member.Member.GetCurrentMember() != null)
{
Media media = new Media(MediaId);
writer.AddAttribute(HtmlTextWriterAttribute.Href, media.getProperty("umbracoFile").Value.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.A);
writer.Write(Text);
writer.RenderEndTag();
}
}
}
Or go with a Razor-macro that checks if the user is logged on. You could use inline razor to do it in a template if you want to.
And to add to the replies...
You can also check for a member being logged in via XSLT.
So 3 different coding techniques to achieve the same results - and why do they say Umbraco is brilliant...
Cheers
Nigel
If you want to protect media files you can use Media Protect.
Jeroen
Thanks everyone for your help.... I guess what I was wondering was can this be done at the Content side of things (within the Ruch Text Editor portion) - On the template side I know this is possible.
@Jeroen: If I use Media Protect - would the link in the Rich Text just not show up? Is that how it works... I can read the material and see..
Thanks,
Allan
is working on a reply...