vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Calling threadicon in a plugin (https://vborg.vbsupport.ru/showthread.php?t=272497)

Mazinger 10-21-2011 06:30 PM

Calling threadicon in a plugin
 
PHP Code:

SELECT thread.threadidthread.titlethread.iconidicon.iconidicon.iconpath
FROM 
" . TABLE_PREFIX . "thread
LEFT JOIN 
" . TABLE_PREFIX . "icon AS icon ON (icon.iconid thread.iconid)
ORDER BY threadid ASC


{

$thread.="<a href='$thread[threadid].html'>$thread[iconpath]</a>";



Let's assume I've the above query & code.

How do I modify it so it can correctly call $thread[iconpath] which is the path of the thread icon?

kh99 10-21-2011 11:20 PM

The iconpath is being retrieved by the query, but I don't know what to tell you about using it because the code you posted is using $thread as a string and an array. What does the "while" line look like?

Mazinger 10-23-2011 12:24 AM

This is a correct code for a plugin, but it still can't call for iconpath.

PHP Code:

$topthreads $db->query_read("
     SELECT thread.threadid, thread.title, thread.iconid, icon.iconid, icon.iconpath
     FROM " 
TABLE_PREFIX "thread
     LEFT JOIN " 
TABLE_PREFIX "icon AS icon ON (icon.iconid = thread.iconid)
     ORDER BY threadid ASC LIMIT 5
     "
);

while (
$topthread $db->fetch_array($topthreads))
{
$favo.="<a href='t$topthread[threadid].html'><img src='$topthread[iconpath]'>$topthread[title]</a>";



kh99 10-23-2011 01:01 PM

Do you have a table prefix defined? If so, you need to add an AS to the FROM line, like:

Code:

$topthreads = $db->query_read("
    SELECT thread.threadid, thread.title, thread.iconid, icon.iconid, icon.iconpath
    FROM " . TABLE_PREFIX . "thread AS thread
    LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON (icon.iconid = thread.iconid)
    ORDER BY threadid ASC LIMIT 5
    ");


But I guess you don't have a prefix, otherwise the query wouldn't work at all.

In any case, I tried that query in PHPMyAdmin and it works, but note that if a thread doesn't have an icon assigned (and it seems that most do not), the iconpath will be NULL.

Mazinger 10-23-2011 01:49 PM

Thanks alot!

I managed to get it work. This is a correct code:

PHP Code:

global $db$vbulletin;

$favthreads $db->query_read("
     SELECT thread.threadid, thread.title, thread.postusername, thread.postuserid, thread.votenum, thread.views, thread.replycount, thread.iconid, icon.iconpath
     FROM " 
TABLE_PREFIX "thread AS thread
     LEFT JOIN " 
TABLE_PREFIX "icon AS icon ON (icon.iconid = thread.iconid)
     "
);

while (
$favthread $db->fetch_array($favthreads))
{
$favo.="<a href='t$favthread[threadid].html'>$favthread[title] $favthread[iconid] $favthread[iconpath]</a><br /><br />";




All times are GMT. The time now is 09:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01191 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete