PDA

View Full Version : Remembering "Collapsed" state on an non-vb page


teonix
06-18-2005, 07:26 PM
I'm trying to display some data from the forum on my main page (its not a vbulletin page, and vbulletin is installed in /forums/ whereas the main page i'm working with is in the main directory of the site)

What i'm trying to accomplish is to display the data in a collapsable box using the collapse function of vbulletin.

So far i've managed to get the actual collapse/expand function working correctly, but I am having difficulties getting it to REMEMBER the last state of the box (collapsed or expanded).

I've checked that it is setting the information into the cookie, and it is, so the problem must lie within reading and interpreting the cookie data?

Any ideas?

Let me know if you need more information...

teonix
06-21-2005, 10:36 PM
Can't anyone help me out?

Basically I just need to know how to read & interpret vb cookie data from a non-vb page...

calorie
06-21-2005, 11:00 PM
What cookie?

teonix
06-22-2005, 06:47 AM
The cookie data for remembering the collapsed / expanded setting for content boxes ...

I think the cookie name is vbulletin_collapse

calorie
06-22-2005, 09:12 PM
That cookie holds the names from onclick="return toggle_collapse('name') ..." and each name is separated by \n so perhaps use something like the following:

$cookie_val = $_COOKIE['vbulletin_collapse'];
echo $cookie_val."<br>\n";
$cookie_arr = explode("\n",$cookie_val);
print_r($cookie_arr);

Andreas
06-22-2005, 09:14 PM
If you IDs are set correctly and vB cookies are accessible it should be stored/loaded automatically - if you have required global.php

teonix
06-22-2005, 11:02 PM
That's what I can't seem to figure out.. I have the following in the top of my page, before any html .. I don't get any errors, so I assume its requiring it properly?

<?PHP
chdir('./forums');
require_once('./global.php');

?>


the onclick="return toggle_collapse('auction_cats')" function is properly setting the cookies, but when you load the page .. the content box loads "expanded" regardless of what you last set it to...


Is there another file or function i'm missing? I am currently including the global.php file and the vbulletin_global.js .....

My code on my mainpage that is trying to use the function is


<div class="myaccsecond">
<a style="float: right;" href="#" onclick="return toggle_collapse('a_cats')">
<img id="collapseimg_a_cats" src="http://www.mywebsite.com/forums/images/buttons/collapse_tcat.gif" alt="Show / Hide" border="0" />
</a>Title Here</div>
<div id="collapseobj_a_cats" style="$vbcollapse[collapseobj_a_cats]">

Content Is In Here

</div>


Looking at this, I realize that I probably need to wrap this in <?PHP ?> tags somehow? Maybe?
style="$vbcollapse[collapseobj_a_cats]"

calorie
06-22-2005, 11:34 PM
Try the attached...

teonix
06-23-2005, 06:14 AM
Hmm, I think i'm getting somewhere now :)

I believe the problem is being caused by the page not parsing the php, so i'm working on fixing this and we'll see where I get.

Thanks Calorie! You've been most helpful :) I'll be sure to bring this up again if I can't solve the rest of problem.