• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Allow users to add their ows text in a action of an existing controller

LordsKing

Active member
#1
Hello :)

I want to add a tab in the profile page of every user, in this tab there is a text box in which the user can write a text; and once the text is write, it is saved !
The text typed in the text box will appear here: domain.com/members/{ name }.{id}/about

Here is my code of the Listener.php file :
PHP:
<?php

class About_Listener
{
    public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        switch ($hookName)
        {
            case 'member_view_tabs_heading':
                $tab = $template->create('about_tab', $template->getParams());
                $rendered = $tab->render();
                $contents .= $rendered;
                break;
            case 'member_view_tabs_content':
                $tabContent = $template->create('about_content', $template->getParams());
                $rendered = $tabContent->render();
                $contents .= $rendered;
                break;
        }
    }
}
My ControllerPublic_Member.php file :
PHP:
<?php

class About_ControllerPublic_Member extends XFCP_About_ControllerPublic_Member
{
    public function actionAbout()
    {
        $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
        $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);

        return $this->responseView(
            'About_ViewPublic_Member_Title', 'about',
            array('user' => $user)
        );
    }
}
And my LoadClassController.php
PHP:
<?php

class About_LoadClassController
{
    public static function extendMemberController($class, array &$extend)
    {
        if ($class == 'XenForo_ControllerPublic_Member')
        {
            $extend[] = 'About_ControllerPublic_Member';
        }
    }
}
Now, my templates !

about_content
HTML:
<li class="profileContent">
    <div align="center">
       <b>About You:</b> <br />
       <textarea rows="15" cols="75" name="$aboutYou"></textarea>      
    </div>
</li>
about_tab
HTML:
<li><a href="{$requestPaths.requestUri}#about">About You</a></li>
about
HTML:
<xen:navigation>
    <xen:breadcrumb href="{xen:link full:members, $user}">{$user.username}</xen:breadcrumb>
</xen:navigation>

<div align="center">About Me <br />
{$aboutYou}</div>
But the text type in the text box doesn't appear :(

Maybe I need tu create a button who save the text typed ?