MyBB Community Forums

Full Version: What attribute should i use?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to know what attribute or what should i type to get the thread url in templates.

Like
{$thread['subject']}--Stands for the subject of the thread.

Similarly i need something which would give me the url if the thread
MyBB has a built in function to do this for you.

get_thread_url($tid, $page, $action)

Example usage:

get_thread_url($thread['tid'], 3)

Will display the thread URL depending on whether the board has friendly URLs active or not, and link to page 3.

Hope this helps...
i am using google seo.
the first thing you gave doesnt actually work on my forum
second one causes an error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/glenv/public_html/showthread.php(985) : eval()'d code on line 26
In which case, this isn't really general MyBB support is it?

Depending on how the threads are built, you can use the different thread fields. My example will only work if you're modifying actual files, and assigning variables. The following will probably work depending on what template you're editing.

<a href="showthread.php?tid={$thread['tid']}">

To make it show subject and thread ID, do the following:

<a href="{$thread['subject']}-{$thread['tid'}">

MyBB's example would be:

<a href="thread-{$thread['tid']}.html">
In PHP, you can get the URL of a thread using get_thread_link() (there is a get_*_link() for other items too, for example announcements, forums, users, ...). However, templates don't let you execute PHP code, so you have to rely on variables that were set before the template is evaluated. Which variables are available depends on the template. For example in the standard forumdisplay_thread templates, the link to a thread is made like so:

<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>