Creating a new LikeHandler

HDJuegos

Active member
Hi, i'm creating a new LikeHandler to allow my users to "Like" more things than Posts and ProfilePosts. Objective: A likehandler for a new content in my forum (like videos in video-directory):

To do it, i create a new content_type:

Data in xf_content_type (content_type,addon_id,fields)


Code:
'myContentType', 'MyAddon', 'a:1:{s:18:"like_handler_class";s:30:"MyAddon_LikeHandler_MyContent";}'

Data in xf_content_type_fields:

Code:
 'myContentType', 'like_handler_class', 'MyAddon_LikeHandler_MyContent'

I do the new likehandler class and put it in LikeHandler folder but i have a problem in my controllerpublic with the next code in actionLike function:

Code:
$latestUsers = $likeModel->likeContent('myContentType', $mycontentid, $contentuserid);

This code returns false and don't create a new like because the next code in Model -> Like.php returns false:

Code:
$likeHandler = $this->getLikeHandler($contentType)

So XenForo don't find the new content_type, althought all fields are filled in DataBase.

I'm doing something wrong?. Thanks in advance
 
Did you clear the content type cache (in the xf_data_registry table)?

If not, make sure you call XenForo_Model_ContentType::rebuildContentTypeCache

I haven't build any new content types, but that REALLY threw me for a loop when I created a new Node Type.
 
Did you clear the content type cache (in the xf_data_registry table)?

If not, make sure you call XenForo_Model_ContentType::rebuildContentTypeCache

I haven't build any new content types, but that REALLY threw me for a loop when I created a new Node Type.

When i need to call rebuildContentTypeCache? From ControllerPublic Class?
 
Great !. Function works, now my contentType can be "liked" by users. A lot of thanks , Dismounted and Arik
 
Hey HDJuegos... I am trying to add a likeHandler to my Media Library mod... Do you mind jotting down EXACTLY everything you did to create a custom like handler?
 
If you look inside xf_content_type_field you'll be able to see the callback class that is specified for a specific content type. You need to do the same - and you can base that off my own modification if you like. You just need to use the default like handlers' code for your purposes (instead of a report handler).
 
The handlers confuse me... there is just way too much going on... and I don't understand "blobs" yet...

Basically I just want the following handlers...

Media Library
  • news feed for when someone submits a media
  • news feed for when someone comments on a media
  • news feed for when someone likes a media
  • like handler for who has liked a media
  • report handler so people can report media
  • moderation queue handler for new media
  • moderation queue handler for comments
Wiki
  • news feed for when someone creates a new article
  • news feed for when someone edits an article
  • news feed for when someone comments on an article
  • report handler so people can report vandalism
  • moderation queue handler for new articles
 
The handlers confuse me... there is just way too much going on... and I don't understand "blobs" yet...

Basically I just want the following handlers...

Media Library
  • news feed for when someone submits a media
  • news feed for when someone comments on a media
  • news feed for when someone likes a media
  • like handler for who has liked a media
  • report handler so people can report media
  • moderation queue handler for new media
  • moderation queue handler for comments
Wiki
  • news feed for when someone creates a new article
  • news feed for when someone edits an article
  • news feed for when someone comments on an article
  • report handler so people can report vandalism
  • moderation queue handler for new articles

Sorry Jaxel, i will post how to do a LikeHandler tomorrow.

Basically i created it into Database, and extends the handler controller. You need to rebuild the content type cache to allow the Like.php call
$likeHandler = $this->getLikeHandler($contentType)

This will posts into the news feed table your "liked" content.
 
Sorry Jaxel, i will post how to do a LikeHandler tomorrow.

Basically i created it into Database, and extends the handler controller. You need to rebuild the content type cache to allow the Like.php call
$likeHandler = $this->getLikeHandler($contentType)

This will posts into the news feed table your "liked" content.
I'm waiting for it, if you have time!
 
Top Bottom