Skip to content
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

Subpage titles are missing in title tag #2367

Closed
gvn opened this issue Dec 19, 2018 · 11 comments
Closed

Subpage titles are missing in title tag #2367

gvn opened this issue Dec 19, 2018 · 11 comments

Comments

@gvn
Copy link
Contributor

gvn commented Dec 19, 2018

Repro: Go to any subpage and look at the title. It shows Mozilla Foundation - .
Expected: Add the subpage title after the hyphen.

screen shot 2018-12-19 at 10 40 54 am

@mmmavis
Copy link
Collaborator

mmmavis commented Dec 20, 2018

Can I assign this ticket to you @gvn 😉 😆

@Pomax
Copy link
Contributor

Pomax commented Jan 29, 2019

Turns out this is still an issue - we should probably get that fixed sooner than later =)

@Dhrumilcse
Copy link

I am getting started with Open Source and I'd like to work on this issue. Can I?

@Pomax
Copy link
Contributor

Pomax commented Jan 31, 2019

Hi @Dhrumilcse, absolutely - have you worked with Wagtail (or Django) and React before?

@Dhrumilcse
Copy link

Thanks @Pomax,
I am familiar with Django but I haven't worked with React before. However; I am ready to learn what's necessary. Also, I was looking through the code base and I think <title> section of base.html is where we need modifications. Correct me if I am wrong and guide me further.

@Pomax
Copy link
Contributor

Pomax commented Jan 31, 2019

That's correct, except each of the top level pages has their own template in https://github.com/mozilla/foundation.mozilla.org/tree/master/network-api/networkapi/wagtailpages/templates/wagtailpages/static that each needs to specify a new title.

If you look at https://github.com/mozilla/foundation.mozilla.org/blob/master/network-api/networkapi/templates/pages/base.html you can see that https://github.com/mozilla/foundation.mozilla.org/blob/master/network-api/networkapi/templates/pages/base.html#L15 already provisions a block called pageTitle that is supposed to render "Mozilla Foundation - [...]", and where the second part is generated from page.meta_title (page is a provided by wagtail as a context variable) and so the problem is that these pages either do not come with, or do not specify, that meta_title property.

@Dhrumilcse
Copy link

Thanks @Pomax
I got it and will work this out. Please assign me this issue.

@Pomax
Copy link
Contributor

Pomax commented Feb 4, 2019

I've added the label to "assigned to contributor", as only people who are part of the github org can be "assigned" to issues.

@Dhrumilcse
Copy link

Hello team, I need guidance.

Because the foundation website contains a lot of modular code and Django's model-view-template pattern, it was a little difficult for me to reverse engineer it and find the solution. Therefore, I decided to create a small Django project and app on my local machine and run a case same as our issue. I found the solution on the local project. Here is my solution, briefly. In the views.py file of the application, while defining the function for specific pages, we pass the 'template tag' with its definition (in our case, the subpage title) as an argument in the render function. Please find the images containing code of the fix and the desired output.

So, once I got this, I went straight ahead to resolve the issue in the main project but couldn't find the file (views.py, I guess) to fix the issue. Can you tell me how should I fix this or if I am incorrect in any way, will you please guide me to the correct one?

[code]
image1

[output]
image2

@xmatthewx
Copy link
Contributor

Ping @alanmoo @Pomax

@alanmoo
Copy link
Contributor

alanmoo commented Feb 7, 2019

It looks like this is working on Opportunity and Campaign pages, because the page editor gets to set the "title" property of the page on those templates.

Two relevant lines of code:
https://github.com/mozilla/foundation.mozilla.org/blob/master/network-api/networkapi/templates/pages/base.html#L14

https://github.com/mozilla/foundation.mozilla.org/blob/master/network-api/networkapi/wagtailpages/models.py#L153-L154

It seems like the main thing we need is for unique page templates to set a title in their model, and the base template should pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants