vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Miscellaneous Hacks - Featured Threads (https://vborg.vbsupport.ru/showthread.php?t=320387)

MarkFL 01-23-2016 06:42 AM

Quote:

Originally Posted by hazem_aliraqi (Post 2563244)
thank you mark i have made the COUNT from sql using php file

how can i find the Featured Threads for each user ?

i don't want a major upgrade its hard to translate for arabic language :)

I need more information regarding the SQL error you get when you try to display the icon next to the names of "Featured Threads" authors in postbits/profiles. You posted that you are getting an error, but not why.

MarkFL 01-23-2016 06:46 AM

Quote:

Originally Posted by hazem_aliraqi (Post 2563245)
this


PHP Code:

MySQL Error   Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
Error Number  
1140 


This is the query:

PHP Code:

    $myfeatured $vbulletin->db->query_first("
        SELECT COUNT(*) AS thread_count, thread.postuserid
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "featuredthreads AS featuredthreads
        ON thread.threadid = featuredthreads.threadid
        WHERE thread.postuserid = " 
$post['userid']
    ); 

I use "COUNT" all the time without a "GROUP BY" clause. What MySQL version are you using?

hazem_aliraqi 01-23-2016 06:57 AM

Quote:

Originally Posted by MarkFL (Post 2563248)
This is the query:

PHP Code:

    $myfeatured $vbulletin->db->query_first("
        SELECT COUNT(*) AS thread_count, thread.postuserid
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "featuredthreads AS featuredthreads
        ON thread.threadid = featuredthreads.threadid
        WHERE thread.postuserid = " 
$post['userid']
    ); 

I use "COUNT" all the time without a "GROUP BY" clause. What MySQL version are you using?



version 5.0.51

MarkFL 01-23-2016 07:16 AM

Quote:

Originally Posted by hazem_aliraqi (Post 2563249)
version 5.0.51

Try changing the query to:

PHP Code:

    $myfeatured $vbulletin->db->query_first("
        SELECT COUNT(*) AS thread_count, thread.postuserid
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "featuredthreads AS featuredthreads
        ON thread.threadid = featuredthreads.threadid
        WHERE thread.postuserid = " 
$post['userid'] . "
        GROUP BY thread.postuserid
    "
); 

In the plugins titled:
  • Show Featured Authors (Postbit)
  • Show Featured Authors (Postbit - Quick Reply)
  • Show Featured Authors (Profile)

If that works, then we will proceed from there. :)

hazem_aliraqi 01-23-2016 07:27 AM

Quote:

Originally Posted by MarkFL (Post 2563251)
Try changing the query to:

PHP Code:

    $myfeatured $vbulletin->db->query_first("
        SELECT COUNT(*) AS thread_count, thread.postuserid
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "featuredthreads AS featuredthreads
        ON thread.threadid = featuredthreads.threadid
        WHERE thread.postuserid = " 
$post['userid'] . "
        GROUP BY thread.postuserid
    "
); 

In the plugins titled:
  • Show Featured Authors (Postbit)
  • Show Featured Authors (Postbit - Quick Reply)
  • Show Featured Authors (Profile)

If that works, then we will proceed from there. :)




awesome
works successfully :)

thank you

MarkFL 01-23-2016 07:34 AM

Quote:

Originally Posted by hazem_aliraqi (Post 2563252)
awesome
works successfully :)

thank you

Okay, now if you wish for this data to show up in the postbit userinfo area (if you are also showing the icon next to the username), try adding this code:

PHP Code:

        $t 'Thread';
        if (
$myfeatured['thread_count'] > 1)
        {
            
$t .= 's';
        }
        
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt title="Featured Thread Author">FT Author</dt> <dd>' $myfeatured['thread_count'] . ' ' $t '</dd>'

within the if statement (at the end within it) in the plugins titled:
  • Show Featured Authors (Postbit)
  • Show Featured Authors (Postbit - Quick Reply)

hazem_aliraqi 01-23-2016 07:58 AM

Quote:

Originally Posted by MarkFL (Post 2563253)
Okay, now if you wish for this data to show up in the postbit userinfo area (if you are also showing the icon next to the username), try adding this code:

PHP Code:

        $t 'Thread';
        if (
$myfeatured['thread_count'] > 1)
        {
            
$t .= 's';
        }
        
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt title="Featured Thread Author">FT Author</dt> <dd>' $myfeatured['thread_count'] . ' ' $t '</dd>'

within the if statement (at the end within it) in the plugins titled:
  • Show Featured Authors (Postbit)
  • Show Featured Authors (Postbit - Quick Reply)



thank you mark

i use this php file with field42



PHP Code:

SELECT COUNT(*) AS thread_count
FROM thread 
AS thread
INNER JOIN featuredthreads 
AS featuredthreads
ON thread
.threadid featuredthreads.threadid
WHERE thread
.postuserid userfield.userid 


is that right ?

MarkFL 01-23-2016 08:03 AM

You should be able to do this without having to use a profile field...you wouldn't want to have to run an additional query for each postbit, redundantly updating a profile field each time.

hazem_aliraqi 01-23-2016 08:09 AM

Quote:

Originally Posted by MarkFL (Post 2563255)
You should be able to do this without having to use a profile field...you wouldn't want to have to run an additional query for each postbit, redundantly updating a profile field each time.


i used Scheduled Tasks for updating user field in every 24 hour

MarkFL 01-23-2016 08:12 AM

Quote:

Originally Posted by hazem_aliraqi (Post 2563256)
i used Scheduled Tasks for updating user field in every 24 hour

I would simply use the query that is already being run to display the information in the postbit, as I suggested above. If you wish to do it differently, then that's fine. :)


All times are GMT. The time now is 10:18 PM.

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.01435 seconds
  • Memory Usage 1,775KB
  • 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
  • (8)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete