Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
692 views
in Plugins by

I've found some issues, I think that the master-branch on github

https://github.com/NoahY/q2a-signatures

has not been tested on q2a 1.6.2.

- the signature section doesn't display at all. In fact the options values in the admin page are not correct :

PHP Notice:  Use of undefined constant QA_PERMIT_USER - assumed 'QA_PERMIT_USER' in /q2a/qa-plugin/q2a-signatures/qa-sig-admin.php on line 18
PHP Notice:  Use of undefined constant QA_PERMIT_ADMIN - assumed 'QA_PERMIT_ADMIN' in /q2a/qa-plugin/q2a-signatures/qa-sig-admin.php on line 20
 
(I think they should be QA_PERMIT_USERS and QA_PERMIT_ADMINS, but I may be wrong)
 
- when I submit a new post (q,a,c), I see the new post and do not see the signature immediately. I have to refresh the page to see it.
 
- the characters counter does not decrease when I type
 
- if I enable the ckeditor4, I have 2 editors active (and not only one)
 
Finally, but I think that this behaviour is "wanted", the signature section is displayed in the user profile page, which should be a read-only page, in my opinion. The widget should be in the account page.
 
 
Q2A version: 1.6.2

1 Answer

+4 votes
by

You might want to use the "about" field for this purpose (at least i did this for another project).

And then output this content below the user info, using an advanced theme:

// override to add about field below user meta below user-meta
function post_avatar_meta($post, $class, $avatarprefix=null, $metaprefix=null, $metaseparator='<br/>')
{
    // called for answer with: post_avatar_meta($a_item, 'qa-a-item');
    
    $this->output('<span class="'.$class.'-avatar-meta">');
    $this->post_avatar($post, $class, $avatarprefix);
    $this->post_meta($post, $class, $metaprefix, $metaseparator);
    $this->output('</span>');
    
    // if post is answer query to get meta
    if($class=='qa-a-item') {
        $userid = $post['raw']['userid'];
        // not anonymous
        if(isset($userid)) {
            // qa_userprofile with: name, about
            // sorted and removed: contact + name + specialized + website
            $userMetas = qa_db_read_all_assoc( qa_db_query_sub('SELECT title,content FROM `^userprofile`
                                                                WHERE `userid` = #
                                                                AND `content` != ""
                                                                ORDER BY title
                                                                ;', $userid) );
            $metaOutput = '';
            $metacount = count($userMetas);
            $name = '';
            $about = '';
            
            if($metacount>0) {
                foreach($userMetas as $metaItem) {
                    // order: contact + name + specialized + website
                    if($metaItem['title']=='name') {
                        $name = $metaItem['content'];
                    }
                    else if($metaItem['title']=='about') {
                        $name = $metaItem['content'];
                    }
                }
                
                $metaOutput = $name.'<br />'.$about;

                $this->output('<div style="clear:both;"></div>
                <div class="bmeta">
                    '.$metaOutput.'
                </div>');

            }
        }
    }
}

by
thank you very much, I'll test your code. To say the truth now I still have to learn what an "advanced theme" exactly is :-) and how it works, so I still need some time to do it ! :-)
I've put it in my todo list !
by
it's quite easy: open qa-theme\yourtheme\qa-theme.php ← adv. theme

There you can override all functions that you find in qa-include\qa-theme-base.php

See examples in snow theme and others.

Important: you can call the original function (add some code and call original) by e.g.:

    function a_list($a_list)
    {
        // call default method output
        qa_html_theme_base::a_list($a_list);
        // add your coding and output
        $dummy = 2;
        $this->output('    my other stuff here '.$dummy);
    }
by
perfect ! thanks
by
Thanks for code it works fine.But can i get some help modifying it ?

I dublicated "if(isset($userid)) {....... } " part for diferent type of signature (i need 2 types of signatures). Everything looks ok, but when one of signature field is filled, another unfilled shows up. How can i solve that ?
...