search

Home  >  Q&A  >  body text

How to make published articles visible only to strangers?

Excuse me, how can I make my published articles visible only to strangers? I want to make a paginated article list. The articles published by everyone are on the same page, but the visibility permissions can be set for the articles published by everyone. Some articles are only visible to friends, some are visible to everyone, and some are only visible to strangers. Visible, for example, A and B are my friends, but C is not. I published an article that is only visible to friends. Then A and B can see the article when they enter the page. C cannot see it. I published an article that is only visible to friends. For articles that are visible to strangers, A and B will not be able to see them when they enter them, but C will be able to see them. How to implement this? It must be able to be paginated

NineNine959 days ago1185

reply all(2)I'll reply

  • 独孤影子

    独孤影子2022-05-13 10:03:23

    The simple design is a friend table, and the article table has publisher and permission (set who can see) fields.

    For example, the query condition for A and B to enter the article page is where permission = all or (the publisher is his friend and the permission is visible to friends)

    c enters where permission = all or (published) The person is not your friend and the permission is visible to strangers)

    If the amount of data is large, you have to think again

    reply
    0
  • Nine

    If you follow your idea, simplify it a bit. The query condition for entering the article page is where permission = all or (permission = visible only to friends and the publisher is my friend) or (permission = visible only to strangers and the publisher is not my friend) or (permission = only visible to me and the publisher is myself), now my difficulty is, how do I know whether the publisher is my friend during mysql query?

    Nine · 2022-05-13 17:44:42
  • Cancelreply