J
J
JTester2021-06-15 17:54:02
PHP
JTester, 2021-06-15 17:54:02

How to tag people?

Hello! Please tell me how to tag people like on Instagram? That is, when you create a post, you can add your own comment, here you can mention people. How it's done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MikUrrey, 2021-06-15
@MikUrrey

1) In the browser: a list of conversation participants is rendered in a JS variable. How depends on requirements. Maybe statically along with the HTML code of the page, maybe dynamically with AJAX, or maybe in "live" mode via WebSocket. The input event handler in the textarea field is assigned the task of displaying a menu of participants at the cursor position if the "dog" @ is pressed (most often it is used for calls). Clicking on the menu item adds the nickname of the interlocutor after "dog"
2) On the server: we get the text and regularly extract substrings of the form "@nickname", collect them and extract from the database of users by nicknames their details, to which we will send notifications (SELECT WHERE IN).
More detailed implementation details appear as you explore the development stack :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question