How to insert logged on username into page content
This seems to be very much more difficult than it should be, so my first assumption is that I'm doing it wrong!!!
I am using the .Net logon controls with a custom membership provider. I want to be able to write "Welcome Gordon, to the support site" where "Gordon" is the name of the currently logged on user.
I created a mega basic user control (label and code to populate it) and used a Macro to place it into the page content (Rich Text Editor / TinyMCE). However, TinyMCE insists on altering the HTML and basically puts "Gordon" on a line by itself!?
Should this method work? If so, what am I doing wrong - or not doing? If there is a better / proper way, please point me in the right direction :-)
<p>Welcome </p> <div umb_macroalias="Support_Forename" ismacro="true" umbversionid="68854cc1-5ef6-42cf-b3e9-626edef11623" umbpageid="1171" onresizestart="return false;" title="This is rendered content from macro" class="umbMacroHolder"><!-- startUmbMacro --><span>This macro does not provides rendering in WYSIWYG editor</span><!-- endUmbMacro --></div> <p>, to the Support site.</p>
within the Editor and looks like this in the actual page
<p>Welcome x</p> Gordon <p>xx, to the Ascend Support site.</p>
I changed the Label to a Literal and it had no effect.
<p>Welcome <div umb_macroalias="Support_Forename" ismacro="true" umbversionid="68854cc1-5ef6-42cf-b3e9-626edef11623" umbpageid="1171" onresizestart="return false;" title="This is rendered content from macro" class="umbMacroHolder"><!-- startUmbMacro --><span>This macro does not provides rendering in WYSIWYG editor</span><!-- endUmbMacro --></div> , to the Support site.</p>
I can't remove the <p> tags ... well, I can but TinyMCE puts them right back in as soon as you save the page! :-(
At the moment, the only solution I know of is to put the macro into a template, which means I will have to put the full sentence into the template / macro - which isn't a good solution at all (not exactly easy to edit the text).
Ideally, I need to stop TinyMCE adding it's own HTML and/or changing the HTML that's already there...
Without using some kind of tokenizing of the editor content (ie - {LoginName}) and then implementing your own version of <umbraco:item /> which parses the content before render I can't think of a way to do this.
If you don't want to have to insert the Macro in the template, maybe you could assign the surrounding <p> a class in TinyMCE and set it to display:inline.
How to insert logged on username into page content
This seems to be very much more difficult than it should be, so my first assumption is that I'm doing it wrong!!!
I am using the .Net logon controls with a custom membership provider. I want to be able to write "Welcome Gordon, to the support site" where "Gordon" is the name of the currently logged on user.
I created a mega basic user control (label and code to populate it) and used a Macro to place it into the page content (Rich Text Editor / TinyMCE). However, TinyMCE insists on altering the HTML and basically puts "Gordon" on a line by itself!?
Should this method work? If so, what am I doing wrong - or not doing? If there is a better / proper way, please point me in the right direction :-)
And it dosesn't show correctly when viewing the page outside tinymce? I presume its because the user control is getting wrapped in a div?
If so what about changing the Label control to a Literal Tag??
Also if you were to use a masterpage then you would be able to use <asp:loginName as long as your custom provider had implmented this.
The required line gets translated into
<p>Welcome </p>
<div umb_macroalias="Support_Forename" ismacro="true" umbversionid="68854cc1-5ef6-42cf-b3e9-626edef11623" umbpageid="1171" onresizestart="return false;" title="This is rendered content from macro" class="umbMacroHolder"><!-- startUmbMacro --><span>This macro does not provides rendering in WYSIWYG editor</span><!-- endUmbMacro --></div>
<p>, to the Support site.</p>
within the Editor and looks like this in the actual page
<p>Welcome x</p>
Gordon
<p>xx, to the Ascend Support site.</p>
I changed the Label to a Literal and it had no effect.
Add stringFormat property to your Control and then use it with combination with string.format
Unfortunately, the LoginName is not their forename, so that's not a solution.
Remove the <p> tags?
Membercontrols for v3 has custom string.format syntax, maybe you can inspire there.
I can't remove the <p> tags ... well, I can but TinyMCE puts them right back in as soon as you save the page! :-(
At the moment, the only solution I know of is to put the macro into a template, which means I will have to put the full sentence into the template / macro - which isn't a good solution at all (not exactly easy to edit the text).
Ideally, I need to stop TinyMCE adding it's own HTML and/or changing the HTML that's already there...
TinyMCE will always wrap a <p> around a macro.
Without using some kind of tokenizing of the editor content (ie - {LoginName}) and then implementing your own version of <umbraco:item /> which parses the content before render I can't think of a way to do this.
If you don't want to have to insert the Macro in the template, maybe you could assign the surrounding <p> a class in TinyMCE and set it to display:inline.
is working on a reply...