Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-30-2008, 12:41 AM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default whats wrong with this ?

i am trying to get the favourite mod from the arcade hack to work on another part of my forum so far php correct but theres a problem with the script the image is not changing on click ? and ideas.

PHP Code:
<script type="text/javascript">

var 
lastfav;


// Favorites handling.
function favsprocess()
{
    if (
xml.handler.readyState == && xml.handler.status == 200 && xml.handler.responseText)
    {
        
thisfav document.getElementById('favs_' lastfav);
        if (
xml.handler.responseText==1)
        {
            
thisfav.src 'images/thread/subfav.gif';
            
thisfav.alt 'Remove Favourite';
            
thisfav.title 'Remove Favourite';
        } else if (
xml.handler.responseText==2)
        {
            
thisfav.src 'images/thread/addfav.gif';
            
thisfav.alt 'Add Favourite';
            
thisfav.title 'Add Favourite';
        }
        
    }
}

function 
dofavs(threadid)
{
    
xml = new vB_AJAX_Handler(true);
    
xml.onreadystatechange(favsprocess);
    
    
lastfav threadid;
    
xml.send('tindex.php''do=processfav&threadid=' threadid);
}


</
script
Reply With Quote
  #2  
Old 01-30-2008, 03:14 AM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not entirely sure, but I don't think you can change a src like that. I think you have to use Image objects, like this:

Code:
<script type="text/javascript">

var lastfav;

var subfav = new Image();
var addfav = new Image();

subfav.src = 'images/thread/subfav.gif';
addfav.src = 'images/thread/addfav.gif';

// Favorites handling.
function favsprocess()
{
    if (xml.handler.readyState == 4 && xml.handler.status == 200 && xml.handler.responseText)
    {
        thisfav = document.getElementById('favs_' + lastfav);
        if (xml.handler.responseText==1)
        {
            thisfav.src = subfav.src;
            thisfav.alt = 'Remove Favourite';
            thisfav.title = 'Remove Favourite';
        } else if (xml.handler.responseText==2)
        {
            thisfav.src = addfav.src;
            thisfav.alt = 'Add Favourite';
            thisfav.title = 'Add Favourite';
        }
        
    }
}

function dofavs(threadid)
{
    xml = new vB_AJAX_Handler(true);
    xml.onreadystatechange(favsprocess);
    
    lastfav = threadid;
    xml.send('tindex.php', 'do=processfav&threadid=' + threadid);
}


</script>
Like I said, I'm not sure, but give that a go.

-- hugh
Reply With Quote
  #3  
Old 01-30-2008, 10:53 AM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

worked a treat m8 thx

PHP Code:
WHERE thread.threadid IN($tindex
its not just seleting the threads with the fav ids ?

the $tindex look like this 1223,3434,5252,5251 etc
Reply With Quote
  #4  
Old 01-30-2008, 03:12 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you post the whole query?

The only thing I can think of without any context is that maybe you are using 'single quotes' rather than "double quotes", so $tindex isn't getting expanded.

-- hugh
Reply With Quote
  #5  
Old 01-30-2008, 08:43 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
     $favcache unserialize($vbulletin->userinfo['tfavcache']);
     
// Favorites
     
$tindex implode(',', (array)$favcache);

    
$threadarray $vbulletin->db->query_read("
        SELECT thread.*, icon.title AS icontitle, icon.iconpath AS iconpath, user.username, user.userid, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid

        FROM " 
TABLE_PREFIX "thread AS thread 
        LEFT JOIN " 
TABLE_PREFIX "icon AS icon ON(icon.iconid = thread.iconid)    
        LEFT JOIN  " 
TABLE_PREFIX "user AS user ON (user.username = thread.postusername)
        WHERE thread.threadid IN(
$tindex$pqr
        ORDER BY 
$sqlsort $sortorder $secondarysortsql
        LIMIT " 
. ($limitlower 1) . ", $perpage "); 
Reply With Quote
  #6  
Old 01-30-2008, 11:14 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nothing obvious wrong with that.

You might want to try assigning the query to a variable and var_dumping() it before it executes, so you can copy and paste the literal query into somelike like phpMyAdmin or a mysql command line, and see what it actually generates.

-- hugh
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:42 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.03603 seconds
  • Memory Usage 2,227KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete