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

Thread prefixes

Discussion in 'Styling and Customization Questions' started by Morgain, Sep 16, 2012.

  1. Morgain

    Morgain Well-Known Member

    I would like to set thread prefixes so that any thread in forums in root Category X has prefix XXX (same name as the Category)

    Please tell me if Prefixes will do this. I do not want this as a user option but automatic default that cannot be user opt out.

    Also what is a Prefix Group?

    Um I made one to test - named one of the coloured buttons and then selected a Categorty under Nodes and Permissions. Left ALL selected for userghroups.​
    No effect whatsoever. When I go in that Category and click to start a new thread it looks just as usual - no prefix even as an option.​

    OK messed up wha? If I click what appears to be a link beside an individual button nothing happens. So I put the prefix text I want in the Title textbox.​
    That has named ALL the buttons with that label.​
  2. Arty

    Arty Well-Known Member

    Its possible.

    First, about prefixes. Prefix groups allow you to group prefixes in groups to make managing prefixes much easier.

    How to do it:

    Create group for predefined prefixes that you'll use for forums, create one prefix for each forum. Then edit forums, in thread prefixes tab select that group and also select default prefix.

    When checking input in function actionAddThread() in XenForo_ControllerPublic_Forum, check if $forum['default_prefix_id'] is set and override user choice with that id. Do you need add-on for this?

    Then edit posting form template to hide prefix selection.
    Morgain likes this.
  3. Morgain

    Morgain Well-Known Member

    Ok thank you I got it working.
    I had to set a prefix for EVERY Forum instead of doing it for a group of forums in a Category YUCK!

    I can see it is working now if I open a new message text box.
    But it doesn't work on all the threads that exist already. That's a shame.
    It will be OK if someone posts a new message on an existing thread I suppose. But when existing threads come up in a Search the prefix will not be there if no post before today.

    I have NO IDEA what that means! I am not a coder.
  4. Arty

    Arty Well-Known Member

    Its ok, use add-on attached to this post. It does exactly what that code change does. If will add forum's default thread prefix to all new threads, even if user selected not to use prefix.

    Attached Files:

    Morgain likes this.
  5. Morgain

    Morgain Well-Known Member

    Oh thank you! Nice guy.

    Possible to make it give the default prefix to all existing threads?
    So if you do searches they show up on older threads?
  6. Arty

    Arty Well-Known Member

    Run this SQL query in phpMyAdmin:
    UPDATE xf_thread 
    SET xf_thread.prefix_id = 
    SELECT default_prefix_id FROM xf_forum
    WHERE xf_thread.node_id = xf_forum.node_id LIMIT 1
    WHERE prefix_id = 0;
    If you have many threads, this query might take a while to execute.
  7. Morgain

    Morgain Well-Known Member

    Thank you. Unfortunately my new webhost does not have cpanel and I have not learned the way to use the system there. I will ask my host who is a coder as well to run this for me.
  8. DRE

    DRE Well-Known Member

    Does this apply a thread prefix to all threads within a subforum even if the thread already has an existing prefix?

    Edit nvm I found what I was looking for: http://xenforo.com/community/thread...-to-all-threads-in-x-forum.31816/#post-364139
  9. Arty

    Arty Well-Known Member

    No, it doesn't apply prefixes to subforums and does not change existing prefixes. To change existing prefixes, remove last line "WHERE prefix_id = 0".
  10. Morgain

    Morgain Well-Known Member

    O managed to do my first queries - and it all looks gorgeous.
  11. kankan

    kankan Active Member


    I am using the theme Flexile
    By default in the system, is it possible to change the prefix while editing a topic ? I couldn't see that function. Or is it a hack to implement ?
    Do you know a way to do this?

    Thank you
  12. Arty

    Arty Well-Known Member

    You should be able to change prefix when editing thread.

    There are two functions: edit thread and edit post. Make sure you are editing thread, not first post. You can edit thread from "thread tools" dropdown when viewing thread or by clicking "edit" link when viewing threads list.
    Jake Bunce likes this.
  13. kankan

    kankan Active Member

    Thank you Arty, yes i saw i could do this for thread post, in fact i was looking for this function while editing the first message of the list (to avoid clicking back to edit message)
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page