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

​​​​​​I have changed the home page title of my website and now I have changed the default homepage of my website "Recent Questions and Answers" to "Recent Activities" homepage. This fix doesn't show my previously customized title. The title "Recent Activities" is coming. Now I want to use a custom title on the "Recent Activities" page?

Q2A version: 1.84
closed with the note: This question has been resolved. Solved by "jair" brother
by
I also had this problem, it was solved with the help of friends, thank you

1 Answer

+2 votes
by
selected by
 
Best answer

Hello Md Belal,

There are two ways of updating this language phrase:

Method 1: If you're using a language pack, then update or add the language phrase 'recent_activity_title' to it; otherwise, the default value is defined in qa-include/lang/qa-lang-main.php:149.

  • Pros: Quick solution
  • Cons: It'll be lost after updating Q2A and/or your language pack

Method 2: Update the language phrase 'recent_activity_title' via plugin override, for example:

function qa_get_request_content()
{
    global $qa_phrases_full;

    // Load language file
    qa_lang('main/recent_activity_title');

    // Override 'recent_activity_title'
    $qa_phrases_full['main']['recent_activity_title'] = $qa_phrases_full['main']['recent_qs_as_title'];

    return qa_get_request_content_base();
}
  • Pros: It'll be preserved after updates
  • Cons: (1) It's a workaround; (2) it'll load that language file even when it isn't actually needed; (3) If updated with a string, instead of another language phrase, it'll show the same phrase, even after changing the language pack

As pointed out in this comment, it'll update both the page title and the page heading. However, if only the page title needs to get updated, a plugin layer will just do the trick:

<?php

class qa_html_theme_layer extends qa_html_theme_base
{
    public function head_title()
    {
        // Template name: 'activity'
        if ($this->template === 'activity' && empty($this->content['favorite'])) {
            $backup = $this->content['title'];
            
            // New title here
            $this->content['title'] = qa_lang_html('main/recent_qs_as_title');

            parent::head_title();
            $this->content['title'] = $backup;
        } else {
            parent::head_title();
        }
    }
}

Tidbit

This customization can also be applied to other pages shown in the top navigation; it's a matter of finding the right language phrase, for example:

and/or finding the right template name:

  • 'qa' for 'Recent questions and answers'
  • 'questions' for 'Recent questions'
  • 'hot' for 'Hot questions'
  • 'unanswered' for 'Recent questions without answers'
  • 'tags' for 'Most popular tags'
  • 'categories' for 'Browse categories'
  • 'users' for 'Top scoring users', 'Newest users', 'Special users', and 'Blocked users'

I hope this answer is helpful.

by
Brother I am ignorant about coding, so simply say the second way because in the first way if I change this in the language file it will change the two red parts shown in my hobby above.I want to change the red part first. The second part will be "Recent Activities".
by
+1
> Brother I am ignorant about coding
Don't worry about that, ask a developer friend to help you out, maybe the one who helped you set your site up.

So do you want to keep the 'Recent Activities' heading (the second part in red) and change the page title (the first part in red) to 'Recent Answers and questions'?
by
Yes bro, I just want to change the title of the page(the first part in red). The headings will remain the same(the second part in red). You just tell me where to change a file, I can do that. I set up the site.
Thanks in advance for resolving my question.
by
Do you want like my site title? I could not upload image in commend. So, just visit my site https://www.ask-ans.com/
and say about this...
by
@Md Belal You're welcome!

Okay. Now the answer covers this case as well. Please follow the plugin
tutorial: https://docs.question2answer.org/plugins/tutorial/#6-reducing-the-number-of-database-queries

Step 6 describes how to create a layer but, since you have more than one
role in your project (owner, web master, developer, ...) I strongly recommend reading it from the beginning to the end.

If you don't have time for reading and implement the plugin by yourself, please reach out to a service provider: https://docs.question2answer.org/services/#q2a-support-and-development or send me a private message.
...