Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1461 posts 1883 karma points
    Nov 02, 2009 @ 20:57
    Gordon Saxby
    0

    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 :-)

  • skiltz 501 posts 701 karma points
    Nov 02, 2009 @ 21:12
    skiltz
    1

    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??

  • skiltz 501 posts 701 karma points
    Nov 02, 2009 @ 21:13
    skiltz
    0

    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.

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 02, 2009 @ 21:29
    Gordon Saxby
    0

    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.

  • Petr Snobelt 923 posts 1535 karma points
    Nov 02, 2009 @ 21:30
    Petr Snobelt
    0

    Add stringFormat property to your Control and then use it with combination with string.format

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 02, 2009 @ 21:30
    Gordon Saxby
    0

    Unfortunately, the LoginName is not their forename, so that's not a solution.

  • skiltz 501 posts 701 karma points
    Nov 02, 2009 @ 21:39
    skiltz
    0

    Remove the <p> tags?

     

    <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>
  • Petr Snobelt 923 posts 1535 karma points
    Nov 02, 2009 @ 21:39
    Petr Snobelt
    0

    Membercontrols for v3 has custom string.format syntax, maybe you can inspire there.

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 02, 2009 @ 22:07
    Gordon Saxby
    0

    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...

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Nov 02, 2009 @ 22:40
    Aaron Powell
    0

    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.

  • Ricky Beard 61 posts 116 karma points
    Nov 02, 2009 @ 22:50
    Ricky Beard
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft