-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set title of the Tag Page #30
Conversation
All Tag Pages have the same forum Title, it's a good idea change the title when you visit a new tag.
Thanks for the PR! We have an issue for this somewhere too so that's good :) Just one thing: the |
Just like this? The parameter |
Just a question, ClientView set the title for search engines, so, the correct way to do this is changing the php file too right? Another point, if ClientView set first title, why the function setTitle is called when app start? |
Yes, that's correct, setting the title in PHP is necessary to set the title for search engines. It's necessary to set the title in both PHP and JS because Flarum is a single-page application, meaning users can navigate between a tag page and a discussion, and then back to a tag page, without hitting the server for new HTML. So this is a little more tricky... The route for a tag page is defined in protected function getView(Request $request)
{
$view = parent::getView($request);
$slug = array_get($request->getQueryParams(), 'slug');
$actor = $request->getAttribute('actor');
$tag = $this->tags->query()->whereVisibleTo($actor)->where('slug', $slug)->firstOrFail();
$view->setTitle($tag->name);
return $view;
} Ultimately this controller should extend Also, something else I didn't notice on my first pass: in the JS you're setting the title in the extend(IndexPage.prototype, 'config', function(value, isInitialized) {
if (isInitialized) return;
const tag = this.currentTag();
if (tag) {
app.setTitle(tag.name());
}
}); Sorry to be nitpicky, but it's good to do these things right :) |
I'm studying the Flarum, then surely I will need advice, thanks! But I did not understand well, my Core does not have the same structure as the current Core ,although the latest version . Currently, information is passed to the app.blade by ClientView.php in render function. The correct would be to override this function, create TagRepository and consult the data by the slug, is not it? |
I'm guessing you're using beta 5 - but the ClientView code has been completely refactored in dev-master. You'll need to update if you want to want to contribute :) |
@terabin Do you need further help to get started with the PHP side of things? |
@franzliedke, any help surely be welcome. I will start this way today. |
@flarum/core what to do with this? As suggested on discord#staff I'd like to propose to close stale PR's based on old code. |
I'm closing this due to inactivity. The full explanation in my comment above still stands. Relevant issue is flarum/framework#495. |
All Tag Pages have the same forum Title, it's a good idea change the title when you visit a new tag.