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

Steps for creating custom alerts

Discussion in 'XenForo Development Discussions' started by zekrose, Sep 16, 2015.

  1. zekrose

    zekrose Member

    Hello everybody, thanks for your previous help. Today, i'm here to ask you the steps for creating custom alerts please.
    ==> What I need, is the different steps i have to do before i can show a custom alert. For example, i've made this line :
    $alertModel->alertUser(17, 17, 'Zekrose', 'comments', '15098', 'answer');
    i researched a bit on the internet, and i found that i have to create a template `alert_comments_answer`. So, i did it and now i'm wondering what do I have to do now because the alerts don't show... Thanks for future help and i apologise for my quite 'beginner' question...
    Have a good afternoon !
  2. batpool52!

    batpool52! Well-Known Member

    You need to add the custom content type as well. Refer to XenForo_AlertHandler_Abstract class
  3. zekrose

    zekrose Member

    And would it be enough ? :)
  4. batpool52!

    batpool52! Well-Known Member

    Most of the times yes.
  5. zekrose

    zekrose Member

    Okay, thank you, i'll try and i'll tell you :)
  6. zekrose

    zekrose Member

    Hm, i'm sorry but i can't see what i need to do to add the custom content type... (I've never developed on XenForo...)
  7. Aayush

    Aayush Well-Known Member

    Check out two tables 'xf_content_type' & 'xf_content_type_field'. Just see how alert_handler_class are added for XenForo and other add ons which have custom alerts. You just insert rows in this table.
    After that create a template with the name 'alert_{content_type}_{action}' which in your case might be 'alert_comments_answer'.

    Thats all you need for your alerts to be displayed.
  8. Lawrence

    Lawrence Well-Known Member

    Normally what Aayush wrote is done during your install routine. Once you inserted your custom alert info into those tables you should then rebuild the content cache:

    XenForo_Application::set('contentTypes', XenForo_Model::create('XenForo_Model_ContentType')->getContentTypesForCache());

Share This Page