Locations Plugin

Hi. Anyone know if it’s possible somehow to add a location to a map by dropping a pin with this plugin?

The locations of some communities are in places that are hard to identify without the use of coordinates, which might put some users off adding a location. Thanks!

2 Likes

I was sure someone requested this before but it’s not on the current list afaics.

Feature requests can be made here: Feature Request

But please note we are usually busy enough maintaining the plugins that new features are rare without someone sponsoring the work.

We would also welcome PRs. This is an especially good feature to add.

5 Likes

Hello,

I noticed an issue with location under topic title. If a user remove a previously added location from /preferences/profile
Then it will show an empty location under topic title instead of remove it.

Screenshot 2022-07-04 at 11.41.30

Thank you :slightly_smiling_face:

Hi!

I’ve modified list/topic-list-item.raw template to display the location on the topic list:

    {{#if topic.location}}
      <div class="title-location">
        {{d-icon 'map-marker-alt'}} {{location-format topic.location opts}}{{location-label-container}}
      </div>
    {{/if}}

But I think my condition isn’t properly written, because if I disable the plugin, the topic list loop breaks.

What would be the correct way to check if the topic location exists in the handlebars template?

1 Like

Overriding this seems a bit extreme, why not use connectors?:

topic-list-after-title OR
topic-list-before-category

Take a look at An interesting strategy for passing properties via raw template plugin outlets

2 Likes

Because I didn’t find the right ones (or maybe they didn’t exist at the time I modified the template, about 2 years ago) :sweat_smile:

Will probably be easier this way, I’ll give it a try, thanks!


Uh… Can’t achieve to use these connectors.

Boring stuff I've tried and looked at

I’ve read Developer’s guide to Discourse Themes.

Assuming this is how we add HTML code in a connector:

<script type="text/x-handlebars" data-template-name="/connectors/topic-above-post-stream/test">
  <div style="height: 200px; width: 200px;background: red"></div>
</script>

I tried

<script type="text/x-handlebars" data-template-name="/connectors/topic-list-after-title/test">
  <div style="height: 200px; width: 200px;background: red"></div>
</script>

But it didn’t work. Is that because topic-list-item is a .hbr and not a .hbs file?

I used Plugin outlet locations theme component but the outlets inside the topic list don’t show up.

I also looked at this What is the difference between raw.hbs handlerbar files and only .hbs handlerbar files?.

Or maybe I just need to create a theme component with an additional file, like this https://github.com/discourse/discourse-topic-thumbnails/blob/main/javascripts/discourse/connectors/topic-list-before-link/topic-thumbnail.hbr?

But here, new connectors are created, while topic-list-after-title and topic-list-before-category already exist… So I’m a bit puzzled here.

2 Likes

Maybe this helps?:

image

image

{{context.topic.location.street}}

or even better:

{{location-format context.topic.location}}

which leads to:

which you can then refine with CSS (eg move to new line).

2 Likes

Yup, perfect, thanks a lot Robert!

So, for those who are interested, this theme component simply adds the locations to the topic list.

3 Likes

Using the outlet is way more elegant, but there is an issue.

The outlet location is just after the topic title… And before the badges div (where it shows the dot indicating unread messages or new topics). The result:

image

I see no easy solution to fix this, even with CSS (I tried stuff).

I also feel that asking for a new outlet in #feature wouldn’t be interesting enough to be added to Discourse.


Edit: I made it so the badge is next to the location. That will do.

image

1 Like

@Canapin once this is mature I’d definitely welcome this as a PR to the main plugin repo so long as:

  • the behaviour was behind a plugin setting

  • the CSS designed in such a way that it doesn’t disturb things if there are other uses of the outlet in addition to this one.

    For example, Topic Ratings also uses the same plugin outlet. Turns out you can chain things via the same outlet. I tested this and it appears they both show if active at the same time (good :+1: ), but you wouldn’t want the CSS to disturb the ratings section unnecessarily.

  • ditto if the setting was OFF

  • Also, if the setting was OFF you’d want the icon to remain in its original position.

2 Likes

Hi!
Any quick clue on how to add or remove CSS rules regarding a site setting? I don’t know how to do that. :see_no_evil:


I also add that images in the documentation links don’t work anymore:

Example:

Hello,

I just updated Discourse (1b56a55f50) and our Locations Plugin is broken. When clicking a button related to the plugin, I get that:

everything is up-to-date, and it was working fine before updating. Please let me know how I can assist in fixing this :slight_smile:

3 Likes

Thanks for the report.

This is now fixed: FIX: Show Map button failure by merefield · Pull Request #69 · paviliondev/discourse-locations · GitHub

4 Likes

Thanks :slight_smile:

This fixes the map! But the other buttons are also broken: when clicking on “find address” when creating a discussion, and clicking the small location icon in a topic list shows the pin button instead.

Btw thank you for this plugin, it’s so convenient.

3 Likes

Ah, sorry, there were more. My quick text search didn’t pick them up.

For now I’ve additionally fixed: FIX: Find Address button not functioning by merefield · Pull Request #70 · paviliondev/discourse-locations · GitHub

You might have to wait a little while for the other one.

3 Likes

Hi folks - I’m interested in adding a State/City field to my new user sign up process, which would then populate the locations map. Is there an easy way to accomplish this? Thanks!

2 Likes

I am having the exact same problem. Can someone help @dodesz and me? :slight_smile: Thank you!

I have another question. When I try to add a location to a new post and click “Save”, the window does not close anymore. In the developer console of the browser I see everytime I hit “Save” the following:

Deprecation notice: DButton no longer supports @action as a string. Please refactor to use an closure action instead. [deprecation id: discourse.d-button-action-string]

User problem or maybe problem with another plugin or component or just a bug?

1 Like

Must be due to a core change as it is also happening on the Events plugin:

1 Like

This PR is in progress, I’ll let you know when it’s done.

5 Likes