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

 https://github.com/NoahY/q2a-featured/blob/master/qa-featured-layer.php

<?php

class qa_html_theme_layer extends qa_html_theme_base {

var $featured_questions;

function doctype(){

$featured = qa_db_read_one_assoc( qa_db_query_sub('SELECT * FROM ^posts q INNER JOIN ^posttags t ON q.postid=t.postid INNER JOIN ^words w ON t.wordid=w.wordid WHERE q.type="Q" AND w.word=$ ORDER BY rand() LIMIT 1', "tag" ));

if($featured && (!$this->request || $this->request=='questions') && !qa_get('sort') && isset($this->content['q_list'])) {

$featured = explode(',',$featured);

foreach($this->content['q_list']['qs'] as $idx => $question) {

if(in_array($question['raw']['postid'],$featured)) {

unset($this->content['q_list']['qs'][$idx]);

}

}

foreach($featured as $id) {

$userid = qa_get_logged_in_userid();

$selectspec=qa_db_posts_basic_selectspec($userid,true);

$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE postid=$) y ON ^posts.postid=y.postid";

$selectspec['arguments'][] = $id;

$question = qa_db_select_with_pending($selectspec);

$usershtml=qa_userids_handles_html(qa_any_get_userids_handles($question));

$options=qa_post_html_defaults('Q');

$q_item = qa_any_to_q_html_fields($question[$id], $userid, qa_cookie_get(), $usershtml, null, $options);

array_unshift($this->content['q_list']['qs'],$q_item);

}

$this->featured_questions = count($featured);

}

qa_html_theme_base::doctype();

}

// theme replacement functions

function q_list($q_list) {

if(isset($q_list['qs']))

foreach ($q_list['qs'] as $idx => $q_item)

if($idx < $this->featured_questions)

$q_list['qs'][$idx]['classes'] = @$q_list['qs'][$idx]['classes'].' qa-q-list-item-featured';

else

break;

qa_html_theme_base::q_list($q_list);

}

function head_custom() {

$this->output('<style>',qa_opt('featured_question_css'),'</style>');

qa_html_theme_base::head_custom();

}

}

Warning: in_array() expects parameter 2 to be array, null given in  (720) : eval()'d code on line 14

Warning: in_array() expects parameter 2 to be array, null given in  : eval()'d code on line 14

Warning: in_array() expects parameter 2 to be array, null given in : eval()'d code on line 14

Warning: in_array() expects parameter 2 to be array, null given in  : eval()'d code on line 14

Warning: in_array() expects parameter 2 to be array, null given in  : eval()'d code on line 14

Warning: in_array() expects parameter 2 to be array, null given in: eval()'d code on line 14

Warning: Invalid argument supplied for foreach() in : eval()'d code on line 18

Warning: count(): Parameter must be an array or an object that implements Countable in  : eval()'d code on line 33 

1 Answer

0 votes
by

Looks like your variable $featured doesn't have a value (null) when it's supposed to be an array, i.e. your database query did not return any results. Do you actually have a tag "tag" in your database? Or should the argument to the database query have been a variable rather than a string?

by
It is difficult for me bro. I am a electrical and electronics engineer. It is tough for me to figure this out. That's why I need expert help bro.
by
Well, I'm trying to help, but like I said, providing more context makes things easier for the people trying to help you.
Anyway, did the config change I mentioned above get rid of that error message? And does the query return the result you expected?
by
No.............................
https://github.com/NoahY/q2a-featured
https://github.com/teddydoors/q2a-question-list-details
Can you look at this plugin ?
I am trying to show random questions in a widget or in question list with image preview with particular tag. Like when a user open the home page everytime he must see a new funny image which contain a tag as "funny"
do you got my point ?
by
+1
"No" the config change did not get rid of the error message, or "no" the query did not return the result you expected?
Also, if you're asking me to patch/write the plugin for you, the answer is no. I'm willing to help you fix an issue you have with the code you're writing, but I'm not going to write your code for you.
...