MyBB Hacks

Full Version: Thread image on threads view
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
well, i had seen this with other forum softwares that allows you to display a image infront of the thread's name in threads display.

when we post an external image by [img] tags in the thread, it will be called automatically to the threads display section and it will be displayed infront of that thread name.

[attachment=252]
[attachment=253]
[attachment=254]

is it possible to make it?
Not by [img] tags, but use something like the XThreads gallery example and modify templates to suit yourself.
I think so.
If it is image upload, I think it is not too difficult to do that with XThreads (using File field type).
Then, modify forumdisplay_thread and/or forumdisplay_threadlist template.
thank you very much imran Smile
(10-23-2010 02:34 AM)Imran Wrote: [ -> ]You can see this too: http://community.mybb.com/thread-47562-p...http://community.mybb.com/thread-47562-post-332031.html
In-loop query...  Yuck!
(10-23-2010 09:11 AM)ZiNgA BuRgA Wrote: [ -> ]In-loop query...  Yuck!

Hi Zinga, what does that mean and why is it a bad thing? Does it affect the efficiency of the board/forum?
It's discouraged as it puts unnecessary additional load on the forum.
http://stackoverflow.com/questions/94621...http://stackoverflow.com/questions/946214/one-sql-query-or-many
http://expressionengine.com/user_guide/d...http://expressionengine.com/user_guide/development/guidelines/performance.html#redunda

Arguably, this may not be a big issue if you don't have a lot of threads, and have very few visitors to your website (coupled with the fact that many MySQL servers are installed locally on the webserver), however it can be considered bad coding practice (and a hallmark of the n00b script kiddie).
It IS more of a problem if you have a remote SQL server (larger sites, or some shared hosting providers do this) as queries are slower due to increased latency.  And if you're a high traffic forum, this can generate significantly more load on the webserver <-> DB server network.

Simple example of an in-loop query:

PHP Code:
for(...) {
  $stuff = $db->fetch_array($db->simple_select(..., 'id='.$id));
}

More appropriate way:

PHP Code:
$query = $db->simple_select(..., 'id IN ('.$ids.')');
$data = array();
while($thing = $db->fetch_array($query))
  $data[$thing['id']] = $thing;
for(...) {
  $stuff = $data[$id];
}


Top one is easier and quicker to write, which is why a lot of people do it, despite it being "bad".

Thanks for the explanation Yumi Smile
Thank you - it was interesting - I spent a while looking around stackoverflow. Some new things on there for me to learn.
Pages: 1 2
Reference URL's