Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 06-06-2008, 01:55 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default "If table is collapsed"

I posted this question in the Design and Graphics discussions but I think this is the right forum for my question.

I've provided some Google Gadgets http://www.google.com/ig/directory?synd=open on my vB 3.6.8 forum in a collapse table. I've got everything working, but would like to prevent the gadgets from downloading if the table is collapsed. So far it isn't a problem since there are only two but if I add more it will slow the page down when it loads. So how do I make a query that will prevent the gadgets from downloading when the table is collapsed ?

Here's the code I'm using for the collapse table:

Code:
<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">

<tbody>

    <tr>

           <td class="tcat" colspan="2"><a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('table_12')"><img id="collapseimg_table_12" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_table_12].gif" alt="" border="0" /></a>Search Links
            </td>

    </tr>

</tbody>
<tbody id="collapseobj_table_12" style="$vbcollapse[collapseobj_table_12]">
        <tr>

               <td class="alt1" width="50%"><center>############## Google Gadget 1 ##############</center></td>
               <td class="alt1" width="100%"><center>############## Google Gadget 2 ##############</center>
               </td>

        </tr>
</tbody>
</table>

So what I need is the code for "If table 12 is collapsed" and "If table 12 is expanded"
Reply With Quote
  #2  
Old 06-06-2008, 07:48 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tables are collapsed on the client side, everything is loaded first then collapsed based on saved settings, so I doubt this is possible.
Reply With Quote
  #3  
Old 06-06-2008, 10:49 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I cleared and then checked my cookies, then collapsed the table and checked again. There's a cookie "vbulletin_collapse" with content="my_table" (the actual name of the table in the forum) when the table is collapsed and empty when it's expanded. Can you write a query based on that?

EDIT: I collapsed several things on my home page and then "vbulletin_collapse" showed content for each feature collapsed. They were separated with %0A
Reply With Quote
  #4  
Old 06-06-2008, 12:01 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what you are asking is not easy

first, you will need to do a check for the cookie (this is the easy part)
HTML Code:
// Clean Cookie Vars 
$vbulletin->input->clean_array_gpc('c', array( 
    COOKIE_PREFIX . 'my_table'   => TYPE_UINT, 
)); 
check based on cookie
HTML Code:
if ($vbulletin->GPC[COOKIE_PREFIX . 'my_table'])
{
 // table is collapsed
 do this;
}
else
{
 do this;
}
however, if table is collapsed (closed) how would the script know when it is expanded (users clicks on it) - the script will need to know this in order to display your gadgets; otherwise, it will just open an empty table

you can solve this in 2 ways (you will have to hire someone to do this for you)
1) ajax
2) skip the collapse/expand javascript and show gadgets based on a value saved for the end-user - this can be a cookie or a setting saved in the database ... either way the page will have to refresh each time the collapse/expand button is clicked


confused
Reply With Quote
  #5  
Old 06-06-2008, 12:51 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is getting way over my head.

Is this a legitimate if query: <if ($vbulletin->GPC[COOKIE_PREFIX . 'my_table'])> ?

If so, I could put it in each td and have it do nothing if true and get the gadget if false.

Are you saying that if the user has the table collapsed from a previous visit and then expands it he will have to reload the page to get the gadgets to download?

--------------- Added [DATE]1212767170[/DATE] at [TIME]1212767170[/TIME] ---------------

Here's another possibility:

The code in template reads


<tbody id="collapseobj_my_table" style="$vbcollapse[collapseobj_my_table]">

in the tbody that collapses.

When I look at the page source actually displayed I get style=" " when it is expanded and style="display:none" when it's collapsed. Can a query be based on this?

--------------- Added [DATE]1212845272[/DATE] at [TIME]1212845272[/TIME] ---------------

It doesn't seem necessary to look at the cookie directly as it is stored in several locations. I found my cookies listed four times in admin CP > Maintenence > View PHP info. They are listed in a group in

Apache Environment under HTTP_COOKIE,

in HTTP Headers Information under cookie,

in PHP Variables under under _SERVER["HTTP_COOKIE"]

and individually in PHP Variables under _COOKIE["......"]

In particlular, the collapse variables for tables are under _COOKIE["vbulletin_collapse"], which lists all the collapsed tables.

Can anyone show me how to make a proper "if" statement based on one of these?
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07661 seconds
  • Memory Usage 2,198KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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