We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Fix this? | Forum

Marcus
Marcus Jul 12 '16
BOL_QuestionService::getInstance()->getQuestionValueLang('relationship', $question['relationship']) . ', ';

this only shows one results but doesn't work when user has selected multiple values only shows base+questions_question_relationship_value_63

How to take care of it?

The  array looks like this:

Array ( [1467] => Array ( [birthdate] => 1983-05-21 00:00:00 [relationship] => 63 [sex] => 1 [address] => 21005 Huelva, Huelva, España ) [2009] => Array ( [birthdate] => 1985-05-10 00:00:00 [relationship] => 2 [sex] => 1 [address] => Huelva, Huelva, España ) [19014] => Array ( [birthdate] => 1983-02-19 00:00:00 [relationship] => 1 [sex] => 1 [address] => Huelva, Huelva, Spain ) )
The Forum post is edited by Marcus Jul 12 '16
dave Leader
dave Jul 12 '16
Please explain more, is this special coding, are you writing your own plugin, does this happen in the demo, is this something that happens when your using your site?  Please be more specific as to the nature of your request, thanks. 
Marcus
Marcus Jul 13 '16
dave thanks so much for your reply. I am working on my own plugin.

Basically I would like to output user question: relationship and match_sex.

I use this:
BOL_QuestionService::getInstance()->getQuestionValueLang('relationship', $question['relationship']) . ', ';

$question['relationship'] contains user relationship or match_sex ID

Now the problem is that it doesn't output when user has selected more than one option in profile question. It only outputs one!

Please teach me how to fetch or out put elationship or match_sex that will show all results.


My code:

[php]class TEST_UserList extends BASE_CMP_Users
{
    public function __construct( array $list, $itemCount, $usersOnPage, $showOnline = true)
    {
        parent::__construct($list, $itemCount, $usersOnPage, $showOnline);
    }

    public function getFields( $userIdList )
    {
        $fields = array();

        $qs = array();

        $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate');

        if ( $qBdate !== null && $qBdate->onView )
            $qs[] = 'birthdate';

        $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex');

        if ( $qSex !== null && $qSex->onView )
            $qs[] = 'sex';
           
           
           
           
           
            //working
            $a = BOL_QuestionService::getInstance()->findQuestionByName('relationship');

        if ( $a !== null && $a->onView )
            $qs[] = 'relationship';   
           
           
           
$questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs);



      foreach ( $questionList as $uid => $question )
        {
            $fields[$uid] = array();

            $age = '';
           
            $locationvalue = "<div>".$question['address']."</div>";

            if ( !empty($question['birthdate']) )
            {
                $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);

                $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']);
            }

            $sexValue = '';
            if ( !empty($question['sex']) )
            {
                $sex = $question['sex'];

                for ( $i = 0; $i < 31; $i++ )
                {
                    $val = pow(2, $i);
                    if ( (int) $sex & $val )
                    {
                        $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
                    }
                }

                if ( !empty($sexValue) )
                {
                    $sexValue = substr($sexValue, 0, -2);
                }
            }


//working
$test = BOL_QuestionService::getInstance()->getQuestionValueLang('relationship', $question['relationship']) . ', ';








            if ( !empty($sexValue) && !empty($age) )
            {
                $fields[$uid][] = array(
                    'label' => '',
                    'value' => $sexValue . ' ' . $age .' '.$locationvalue.' '.$test
                );
            }
        }

        return $fields;
    }
}
[/php]
ross Team
ross Jul 13 '16
Topic was moved from General Questions.
dave Leader
dave Jul 13 '16
if you are only getting the return value for one selected field and not all of them, then more than likely you are not submitting the array or options properly.  


Either the function call you are using is not designed for an array input, or you are not calling the function for each selected value. 


In your loop if you store the result in an array for each loop like this


$myarrayname[] = $result;  


it will store the result each loop (pack them one by one) and then when you are done you can just look at the $myarrayname value and all your rows should be in there. 

Marcus
Marcus Jul 14 '16
Buddy thanks so much. Please what function will output each selected value? I am still a beginner and not familiar with all oxwall functions.

In the code above what would you do to return all the selected values for relationship?
The Forum post is edited by Marcus Jul 14 '16
Marcus
Marcus Jul 14 '16
Whenever the user has more than one value selected it returns similar:
base+questions_question_relationship_value_63
dave Leader
dave Jul 14 '16
are you using skadate?   I ask only because oxwall does not use the match process
The Forum post is edited by dave Jul 14 '16
Marcus
Marcus Jul 14 '16
Nope it's oxwall! Buddy my code is a few posts above.  Whenever user has more than one value selected on question in shows some like this: base+questions_question_relationship_value_63

How would you use that code to show the entire content of user relationship in userlist?
The Forum post is edited by Marcus Jul 14 '16
dave Leader
dave Jul 14 '16
ok ill take a look asap and get back to you, prob be in the morning as i am in the middle of table creation. 
Marcus
Marcus Jul 14 '16
Thanks buddy so much. This seem to return array with all the data: $questions = BOL_UserService::getInstance()->getUserViewQuestions("1");

I feel like this is too much case I only need relationship not stuff like password, email and so on!














Marcus
Marcus Jul 14 '16
This seem to return the info I need. Now how do I apply useridlist to this code that only requires one id? yet still keeping it in the loop.

$userId = 1;
$questions = BOL_UserService::getInstance()->getUserViewQuestions($userId);

if ( !empty($questions['data'][$userId]) )
        {
            $data = array();
            foreach ( $questions['data'][$userId] as $key => $value )
            {
                if ( is_array($value) )
                {
                    $questions['data'][$userId][$key] = implode(', ', $value);
                }
            }
        }

print_r($questions['data']);
dave Leader
dave Jul 14 '16
is this what you need 



Attachments:
  test.txt (1Kb)
Marcus
Marcus Jul 15 '16
Oh my goodness Dave you are truly the leader thanks you soooo much for the time you dedicated solving my issue I love you bro thanks really.
dave Leader
dave Jul 15 '16
you are very welcome glad it helped you :)