1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting the thread_id from the load_class_view Event Listener

Discussion in 'XenForo Development Discussions' started by robdog, Oct 11, 2011.

  1. robdog

    robdog Well-Known Member

    I am trying to get the pages current thread_id when viewing a thread on the page.

    Is there an object available to me or a static function I can call to get the thread info? Similar to:
    $visitorId = XenForo_Visitor::getUserId();

    Thanks.
     
  2. ragtek

    ragtek Guest

    What do you want to do?

    If you're in the view object, you can access $this->_params where you should find the thread data
     
    robdog likes this.
  3. robdog

    robdog Well-Known Member

    $this is not available to me. I am extended the load_class_view with the class being XenForo_ViewPublic_Thread_View

    I get an error when I try to access $this.

    I basically just want to get the User Id and the Thread Id when someone views a thread.
     
  4. ragtek

    ragtek Guest

    and then?:p

    why not use a available template hook or extend the controller?
     
    robdog likes this.
  5. ragtek

    ragtek Guest

  6. robdog

    robdog Well-Known Member

    haha. I am pretty sure I using the wrong event listener.

    I was thinking about extending the controller, but I was hoping for a simple static function to get the thread_id of the current thread being viewed.

    I will get back after it and see if I can figure this stuff out! Damn you Zend!
     
    Fuhrmann likes this.
  7. ragtek

    ragtek Guest

    that's not zend:p
     
    Fuhrmann likes this.
  8. robdog

    robdog Well-Known Member

  9. robdog

    robdog Well-Known Member

    Damn you ROBDOG!
     
  10. Fuhrmann

    Fuhrmann Well-Known Member

    Maybe you can use the:

    PHP:
    public function actionAddReply()
    in XenForo/ControllerPublic/Thread.php
     
  11. robdog

    robdog Well-Known Member

    Yup, that will get called if I extend that function. Now just need to figure out the proper response return to not screw up the actual reply functionality. Again, trying to increment a value in the thread column when a reply happens.
     
  12. Fuhrmann

    Fuhrmann Well-Known Member

    What exactly you want to do? Maybe we could help.
     
  13. robdog

    robdog Well-Known Member

    I have a column in the thread table called "hot_count". I would like to increment the value of that column by 10 when someone replies to a thread.
     
  14. robdog

    robdog Well-Known Member

    Nevermind, got it all figured out!

    Moving on to the next step! :)
     
    Fuhrmann likes this.
  15. robdog

    robdog Well-Known Member

    Thanks you 2 for your help btw. Here is what I am working on btw:
    http://www.gatorenvy.com/email-campaign

    Basically a page that auto updates so I can run a cron that auto creates a Mail Chimp campaign once a week to send to my subscribers. Will add more customizations to the campaign template at a later date, but this is good enough for now! :)
     
    Fuhrmann likes this.

Share This Page