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

New template hook: thread_edit_fields_main

Discussion in 'XenForo Development Discussions' started by Jawsh, Apr 8, 2016.

  1. Jawsh

    Jawsh Formerly null0

    PHPBB has this feature I've been hurting for for years so I'm making it myself.

    [​IMG]

    See those subtitles? I want those. I can hook a new field into the thread creation form thanks to the hand-dandy hook thread_create_fields_main, but no equivalent hook exists for the edit thread form.

    [​IMG]
    [​IMG]

    thread_create
    [​IMG]

    thread_edit
    [​IMG]

    So what I'm going to do is add a thread_edit_fields_main, but if I give this add-on out, it'll require everyone to do the same. That's a real drag. It'd be really great if that hook existed by default; I see no reason why it shouldn't.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    No, which bit on the screenshot is a "subtitle"?

    Don't use template hooks. Use template modifications: Appearance > Template Modifications
     
  3. Jawsh

    Jawsh Formerly null0

    Ack, that's a forum description. I took the screenshot in a hurry, but it turns out Topic Descriptions were a popular mod I used. Here's a forum I could find that used it:
    [​IMG]

    The thin text between the bold title and topic statistics is the thread descriptions. I need it for my forum because people tend to make thread titles with descriptions, like "1984 - George Orwell's predictions for modern authoritarian government and mind control", which is really messy. I'd prefer it if topic titles were literally just what the thread was about, and topic descriptions would be concise user generated excerpts.

    Is this specific to this request, or should I be using template modifications to inject HTML every time I need it? The mods I learned from used hooks exclusively, I've never even heard of this feature before.


    As as aside, it turns out edit_thread is where that form is from, not edit_thread_title. I thought maybe edit_thread_title was the AJAXified edit button on the thread_list, but that's not the case, so in total there's 4 places for this input field, lol.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    That makes more sense ;)

    Absolutely. Template modifications were added in XF 1.2 back in 2013. Template hooks have been deprecated since then. We've not yet removed them, but realistically we could if we wanted to. We certainly haven't added any new ones (nor will we be). They certainly won't feature at all in XF 2.0.

    To be fair, template hooks are a good introduction into how XF development works, so the tutorials (which are fairly old now) are still useful.
     
  5. Jawsh

    Jawsh Formerly null0

    Okay, these are a lot better than I thought just hearing the name "template modifications". I thought this would automatically inject HTML into templates during installation, but it looks like it's a ephemeral change that only affects the rendered page. Very robust, I do like this.
     

Share This Page