Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Multiline field on user profile page

I want to have a rich text and multilines field in my user profile page.
I tried to use the status field but not convenient and the line breaks are lost when you display.
What would be the easiest way to do that ?

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    I don't think there is an easy way. Instead of changing the ProfileExtender in such a way, it might be better to write a small plugin yourself. This is a basic plugin which I have written long ago and which doesn't do what you like, but it shows you how easy adding a field to the profile is.
    You can then simply show all texts with echo Gdn_Format::html(...) or echo Gdn_Format::markdown(...)

    migswdhgtonight
  • Hum thanks for help. Not easy for my programming level but I will try.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    If you have a level above zero, you will find it is not as hard as you might think. Just begin and ask whatever you like.

  • OK then. First : how to display a rich text field instead of a simple input ?

    I got to replace TextBox by what ?

    // extra field for version info in edit profile
      public function ProfileController_EditMyAccountAfter_Handler($Sender) {
        echo '<li>';
        echo $Sender->Form->Label(T('Vanilla Version Used'), 'UsersVanillaVersion');
        echo $Sender->Form->TextBox('UsersVanillaVersion', array('class' => 'InputBox SmallInput'));
        echo '</li>';
      }
    
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    In the code above, you use Vanillas Form class to output special html elements: the label gives a label tag and the textBox gives a html input tag.
    There are a lot more form elements in that class. Look at that one

    echo $Sender->Form->BodyBox('UsersVanillaVersion');

  • OK thanks R_J. Now I display the textarea in my user profile.
    But how do I get the value of this field and display it in the textarea ? (so the user modify this value instead of typing everything again each time there is a modification)

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    The answer depends on where that box appears and how you have implemented it. In theory, you would have to hook into an event of the model that is fired when the data for this view is fetched.
    If you show it on a dedicated page, you have to fetch that info by yourself.

    You would have to present more information to us. Best thing would to show the method which creates that input box


    I've seen your comment in another discussion, that you cannot switch back to default theme because you have customized so much. That is dangerous. In some cases there is no way around it, but since you seem to be quite new to Vanilla, I guess in most cases you have taken the most straight forward way to solve your problem. That is not always the best way.

    I've helped several times to "clean up" themes so that the required changes are made the Vanilla way, which keeps your forum being upgradable. If you do not mind uploading your theme to GitHub I will take a look at it and do some PRs if possible.

    Maybe it would make sense to make some changes dedicated plugins and not to pack everything in the themes themehook file.
    Just imagine Vanilla will implement a feature that you have taken care of with some parts of your themehooks file. Stripping that not needed code from your theme is far more dangerous than simply deactivating one plugin.

    IRAQIMS
Sign In or Register to comment.