Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
414 views
in Themes by

Hi,

In my website, I would like to show an alternate logo which is suited for mobile theme. Any reocmmendations are appreciated.

1 Answer

+5 votes
by

Assuming your theme or any plugin is not interfering with the generation of the needed HTML to display the logo, this should work.

1. Edit the qa-theme/<your-theme>/qa-theme.php file

2. Add (or merge, if it already exists) this function:

public function initialize()
{
    $logoUrl = 'http://www.question2answer.org/images/question2answer-qa-logo-white-454x40.png';  // replace by the URL of your logo
    $logoWidth = 40;  // replace by the width of your logo
    $logoHeight = 20;  // replace by the height of your logo

    if (qa_opt('logo_show') && qa_is_mobile_probably()) {
        $this->content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' .
            '<img src="' . qa_html(is_numeric(strpos($logoUrl, '://')) ? $logoUrl : qa_path_to_root() . $logoUrl) . '"' .
            ($logoWidth ? (' width="' . $logoWidth . '"') : '') . ($logoHeight ? (' height="' . $logoHeight . '"') : '') .
            ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>';
    }
}

3. You should only change the initial values of $logoUrl, $logoWidth and $logoHeight. Note they're equivalent to the options in section admin/layout. Leave the rest unchanged.

...