Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

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 Ex-Fanboy Munich Admin

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

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

  • R_JR_J Ex-Fanboy Munich Admin

    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 Ex-Fanboy Munich Admin

    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 Ex-Fanboy Munich Admin

    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.

Sign In or Register to comment.