Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
769 views
in Q2A Core by
edited by

Hi i just discovered Q2A and i have to say that its a great forum platform. I am trying to learn how it is work and i m very excited of its features. However i am trying to add the user's profile field "location" inside the drop down user menu at the top bar but cant make it work :(

Until now i tried to add this piece of code inside my qa-theme file:

    $location = isset($content['raw']['profile']['location'])?$content['raw']['profile']['location']:'';

 and then echo the result with:

echo $location;

but it doesnt display anything and also it doesn't return any errors  !

What i m doing wrong here ? it would be great if any of the Q2A developers could give me some help here.

Q2A version: 1.7
by
@sama55 @pupi i tried almost everything but i cant understand how to output this field :( On other php frameworks you have to define the variable in the controller file and then outputh the result in the view file. However i found the array $profileFields that has stored the location, name, website etc but dont know how to output only the location.

1 Answer

+2 votes
by
selected by
 
Best answer

In case of SnowFlat theme ...

"Admin" > "Layout" > "Custom HTML in <head> section of every page:"

<style>
.qam-logged-in-location {
    padding: 10px 20px;
    border-bottom: 1px solid #2c3e50;
}
.qam-logged-in-location:before {
    content: ' ';        /* Hex code of "location" icon is unknown ... */
    font-family: "fontello";
    display: inline-block;
    width: 1em;
    background-color: #2c3e50;
    padding: 5px;
    margin: 0 10px 0 0;
    text-align: center;
    line-height: normal;
    border-radius: 1em;
}
</style>

qa-theme/SnowFlat/qa-theme.php

public function logged_in()
{
    parent::logged_in();
    if (qa_is_logged_in()) {
        $userpoints = qa_get_logged_in_points();
        $pointshtml = $userpoints == 1
            ? qa_lang_html_sub('main/1_point', '1', '1')
            : qa_html(qa_format_number($userpoints))
        ;
        $this->output('<div class="qam-logged-in-points">' . $pointshtml . '</div>');
        
        $userprofile = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec(qa_get_logged_in_handle(), false));
        if(isset($userprofile['location']))
                $this->output('<div class="qam-logged-in-location">' . $userprofile['location'] . '</div>');
        /*
        echo '<pre>';
        echo 'userprofile = '.print_r($userprofile, true);
        echo '</pre>';
        */

    }
}

by
Thanks @sama55. It worked perfect!  Instead of admin>layout>custom html i add my css code inside my theme stylesheet file ;)
...