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

how to use $thread in bb_code_tag_attach ?!

Discussion in 'XenForo Development Discussions' started by TBDragon, Mar 17, 2014.

  1. TBDragon

    TBDragon Active Member

    hi i just wondering how i can use $thread in bb_code_tag_attach ?!

    so i can use the {$thread.title} for example as alt for attachment !??

    i tried many times but i dono y its not called !!

    even i try
    {xen:helper dump, $thread} just to see if any thing related to $thread is called or used or any thing that let me know if its possible to know
    but its says NULL !!

    so any one have an idea about this ?!

    our big saver @Chris D do u know any thing about it ?!

  2. Chris D

    Chris D XenForo Developer Staff Member

    The thread title probably wouldn't be appropriate for alt text on an image, anyway.

    Try {$attachment.filename}

    That should be available there (at a guess).
    TBDragon likes this.
  3. TBDragon

    TBDragon Active Member

    i know that {$attachment.filename} will work there but what if i want the alt of the attachments be the title thread !!

    the alt of attachment can be changed i try other things ( dummy ) and its change but y with $thread doesnt !!

    is this how its implementing ?!
  4. Nobita.Kun

    Nobita.Kun Well-Known Member

    If say null because the variable $thread didn't assigned to `bb_code_tag_attach`. You need assign before use it :)
    TBDragon likes this.
  5. TBDragon

    TBDragon Active Member

    u say it , HOW to assign it or get the values of $thread
    how i can grab/get/retrive the $thread.title /.id etc ...

    in that template !!
  6. Chris D

    Chris D XenForo Developer Staff Member

    The $thread parameter isn't available to the bb_code_tag_attach template.

    In fact, attachments don't really have any concept of what thread they are in. Attachments are attached to posts. They aren't attached to threads.

    You would need to extend some code to get that information.
  7. TBDragon

    TBDragon Active Member

    so this mean i need to overwrite the attach bbcode in way that i use the way its done the normal job + grab other data i want to do like the $thread ?!
  8. Chris D

    Chris D XenForo Developer Staff Member


    But I'd actually recommend extending XenForo_Model_Post::getAndMergeAttachmentsIntoPosts...

    Don't quote me on this but I *think* that is how the attachment record gets into each post record. At this point you have a view of all posts in a thread and all their attachments. So you can loop through that, get the thread ID and do a single query for the full thread record. Then merge that into each $post['attachments'] array.

    By the end of it you should be able to use $attachment.thread['thread_id'] or whatever you want.
    TBDragon likes this.

Share This Page