Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Questions with selected Answers should have Solve for Search Engine

+4 votes
143 views
asked Mar 20 in Q2A Core by Dr-Hack
When ever an answer is selected the "Solved" should be added to the Question for Search Engines ... or there are any plugins already doing the same ?

3 Answers

+3 votes
answered Mar 21 by sama55
selected Mar 22 by Dr-Hack
 
Best answer

Is your hope satisfied with this hack?

Source: qa-include/pages/question-submit.php
Function: qa_page_q_single_click_a()
Changes:

if (qa_clicked($prefix.'doselect') && $question['aselectable'] && ($allowselectmove || ( (!isset($question['selchildid'])) && !qa_opt('do_close_on_select'))) && qa_page_q_click_check_form_code($answer, $error) ) {
    qa_question_set_selchildid($userid, $handle, $cookieid, $question, $answer['postid'], $answers);
    // [START]
    if(qa_opt('do_close_on_select'))
        qa_question_close_other($question, $answer, qa_lang_html('main/answer_selected'), $userid, $handle, $cookieid);
    // [END]

    return true;
}

if (qa_clicked($prefix.'dounselect') && $question['aselectable'] && ($question['selchildid']==$answer['postid']) && ($allowselectmove || !qa_opt('do_close_on_select')) && qa_page_q_click_check_form_code($answer, $error)) {
    qa_question_set_selchildid($userid, $handle, $cookieid, $question, null, $answers);
    // [START]
    if(qa_opt('do_close_on_select'))
        qa_question_close_clear($question, null, $userid, $handle, $cookieid);
    // [END]

    return true;
}

commented Mar 22 by Dr-Hack
i have done the changes , will be able to view there success after google index some question / answer .. so let see :)
+4 votes
answered Mar 20 by sama55
This would be the option related to your wishes.

"Admin" > "Posting" > "Close questions with a selected answer"

But, What does "for Search Engines" mean?

Related thread:
http://www.question2answer.org/qa/37990/improvement-suggestion-of-auto-close-in-v1-7
commented Apr 5 by Dr-Hack
hello again,
ok so after the changes, once the answer is selected as a "best Answer" it shows "Some Question [closed]" What i was hoping was that it show something like " [Solved] Some Question" that way people searching a similar query on google will get an idea that the query has a solution and it is marked as solved.
hope what i am saying is making some sense ...
thanks
commented Apr 5 by sama55
edited Apr 5 by sama55
You can show "Solved" instead of "Closed" with overriding two layer functions of qa-include/qa-theme-base.php.

/*
public function title()
{
    $q_view = @$this->content['q_view'];

    // link title where appropriate
    $url = isset($q_view['url']) ? $q_view['url'] : false;

    if (isset($this->content['title'])) {
        $this->output(
            $url ? '<a href="'.$url.'">' : '',
            $this->content['title'],
            $url ? '</a>' : ''
        );
    }

    // add closed note in title
    if (!empty($q_view['closed']['state']))
        $this->output(' ['.$q_view['closed']['state'].']');
}
*/
public function title()
{
    $q_view = @$this->content['q_view'];

    // link title where appropriate
    $url = isset($q_view['url']) ? $q_view['url'] : false;

    if (isset($this->content['title'])) {
        // add closed note in title
        if (!empty($q_view['closed']['state']))
            $this->output('[Solved] ');
        $this->output(
            $url ? '<a href="'.$url.'">' : '',
            $this->content['title'],
            $url ? '</a>' : ''
        );
    }
}

/*
public function q_item_title($q_item)
{
    $this->output(
        '<div class="qa-q-item-title">',
        '<a href="'.$q_item['url'].'">'.$q_item['title'].'</a>',
        // add closed note in title
        empty($q_item['closed']['state']) ? '' : ' ['.$q_item['closed']['state'].']',
        '</div>'
    );
}
*/
public function q_item_title($q_item)
{
    $this->output('<div class="qa-q-item-title">');
    $this->output('<a href="'.$q_item['url'].'">');
    $this->output(empty($q_item['closed']['state']) ? '' : '[Solved] ');
    $this->output($q_item['title']);
    $this->output('</a>');
    $this->output('</div>');
}

Reference:
http://docs.question2answer.org/plugins/layers/

The above logic is a way to display fixed English text ("[Solved] "). Customizing language files is even better.

http://docs.question2answer.org/translate/
Refer to "Customizing selected URLs or phrases".
 qa-lang/custom/qa-lang-main.php
For example, 'closed' => 'Solved'
+1 vote
answered Apr 5 by pupi1985

I believe this is just a matter of changing the display of the title of the question in the question lists and in the question view. I wouldn't change the actual content of the question title. The steps below work for SnowFlat but some basic PHP programming skills would allow you to merge the changes into any theme (or, even better, as a plugin layer).

1. Edit the qa-theme/SnowFlat/qa-theme.php file

2. In order to add the text in question lists, add these lines exactly in this line:

if (isset($q_item['raw']['selchildid'])) {
    $q_item['title'] = '[Solved] ' . $q_item['title'];
}

3. In order to add the text in question views, add these lines exactly below this line:

if (isset($this->content['q_view']['raw']['selchildid'])) {
    $this->content['title'] = '[Solved] ' . $this->content['title'];
}

...