Page Index Toggle Pages: 1 Send Topic
Normal Topic Post like button added (Read 56 times)
nixnut
Forum Administrator
*
Offline


I love YaBBForum 3

Posts: 160
Location: New Zealand
Joined: 14.07.2026
Gender: Male
Post like button added
09.11.2026 at 23:52:19
        1 likes
Report Post  

### 1. Data Storage & File Structure (`Post.pm` & Thread Files)

* **Dedicated Storage Slot:** Configured index `12` in the pipe-delimited post rows inside `$datadir/$thread.txt` to hold comma-separated lists of usernames who liked each individual post.
* **Trailing Field Protection:** Added a `-1` limit to all `split /\|/xsm` operations across read/write routines. This forces Perl to preserve trailing empty fields (`||||`), preventing record structure corruption on posts without replies or attachments.

### 2. Template Integration (`Display.pm` & Templates)

* **Template Tags:** Integrated `{yabb postlikes}` and `{yabb postlikeimage}` into the post display rendering loop.
* **Dynamic Button Toggle:** Implemented explicit state checks using an `if/else` block so the UI cleanly switches between the **Like** button and the **Dislike (Unlike)** button depending on whether your username is already recorded in index `12`.
* **Interactive Count Popup:** Made the like count text clickable, launching a popup window that passes the thread ID, message index, and scroll position.

### 3. Action Controllers (`Like.pm`)

* **`PostLikeInc`:** Safely appends the current user's username to index `12` after verifying they haven't already liked the post and aren't a guest.
* **`PostLikeDec`:** Filters out the current user's username from index `12` cleanly when unliking.
* **`PostLikeList`:** Gathers the list of liking members, sorts them alphabetically by real name, and renders the popup window with profile links and a close button that preserves scroll position.

### 4. Dispatcher Routing (`SubList.pm`)

* Registered the custom actions (`postlikeinc`, `postlikedec`, and `postlikelist`) directly to `Like.pm` so YaBB routes incoming requests seamlessly.

---
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic
Bookmarks: Digg Facebook Linked in reddit X