Closed shanikadhettige closed 7 years ago
There is no relation between news and countries (there is such connection between projects and countries, because projects have locations) so we cannot achieve this right now.
Since on the country/location page, we can list the News on the side, for sure we can do the other way around? Can we list the location the News is linked to?
@apercas
Hi, sadly we cannot display the country of each news from the news list as there is no such information, news are not related directly to a country. The only thing I can think of is adding an optional custom field that specifies the country or displaying again the tags, where we have the country linked (in between of other tags).
How is that possible? We are able to display the News related to a country on the country pages? So there must be a link from the News to the country ? As we had talked about, it would actually more natural to link a News to a Country from the News page, rather than the other way around from a user prospective.
Yes, we're displaying the news related to a country using that very tag, like here: https://opendri.org/tag/sri-lanka/
From the news list (and not from a project or a given news) the only way to get the country of a piece of news is reading its tags.
So when on this page: https://opendri.org/project/sri-lanka/ The News on the right are linked using the tags? I thought that was done using a custom field on the country ?
There is no such entity as country (but we have project, which is the most similar one), that's why we cannot go backwards from the news list. We're taking the country name from the title of the project, actually, and that's how we get the relation for the news. We display the related ones and then we build a link to the tag for that country.
By country, I meant project. I still don't understand why we cannot access the project that is related to a news ? It should be easy to display the project name to which a news is related ?
Hi,
Let me know if this discussion is still relevant. Currently, news seem to be loaded from a custom field on the project page, so this is a one directional relationship.
@vdeparday let's discuss
I added the support for a new field, called "countries", inside a news page.
The screenshot above is from https://opendri.org/wp-admin/post.php?post=2097&action=edit You can do the same for every news article, to specify which country it should be linked to.
On the frontend, the country names will show up as requested. If they don't, it's most likely because there isn't yet a tag with that name. So, for example, if OpenDRI.org starts covering a new country, you will need to create a tag with that country's name before you can use the mechanism above.
Also, the links in the news list page will forward to the tag page. This is the same behavior as we have already on the other news tags, so I believe it makes sense to keep it consistent. Again, for a project to appear inside a tag's page, it needs to be tagged with the appropriate country, otherwise it won't be visible.
I understand this is a bit to take in, so if you have any questions, feel free to reach out.
Thanks
@vdeparday i understand this is a more manual solution than you were looking for, is this OK for you?
Please add the relevant countries to the bottom left of each news box (along with the categories you already have listed)