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-28-2008, 03:11 AM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Dynamic code for collapsible boxes error on ']'

I get the error "Parse error: syntax error, unexpected '"', expecting ']' in /home/dysplace/public_html/eve-ocf/eveit.php on line 161" when trying to run
PHP Code:
$corp "ocf";
$ocfapidata "<tbody><tr><td class=\"thead\" colspan=\"3\"><a style=\"float:".$stylevar[right]."\" href=\"#top\" ";
$ocfapidata .= "onclick=\"return toggle_collapse('359_eveit_".$i."')\"><img id=\"collapseimg_359_eveit_".$i."\" ";
//OFFENDING LINE BELOW
$ocfapidata .= "src=\"".$stylevar[imgdir_button]."/collapse_thead$vbcollapse[collapseimg_359_eveit_".$i."].gif\" alt=\"\" ";
//OFFENDING LINE ABOVE
$ocfapidata .= "border=\"0\" /></a>".$attr[$corp]['charactername']."</td></tr></tbody><tbody id=";
$ocfapidata .= "\"collapseobj_359_eveit_".$i."\" style=\"\$vbcollapse[collapseobj_359_eveit_".$i."]\"><tr><td class=\"alt1\$
$ocfapidata .= "Character: <font color=\"#FF7800\">".$attr[$corp][$i]['charname']."</font><br />";
$ocfapidata .= "</font></td><td class=\"alt1\">";
$ocfapidata .= $skills[$sit[$corp][$i]['trainid']]['name'];
$ocfapidata .= " ".$sit[$corp][$i]['trainto']."</td><td class=\"alt1\">".$sit[$corp][$i]['trainleft']."</td></tr>";
$ocfapidata .= "</tbody>"
I have $ocfapidata in my template, and it displays just fine when I change the offending line to
PHP Code:
$ocfapidata .= "src=\"".$stylevar[imgdir_button]."/collapse_thead$vbcollapse[collapseimg_359_eveit_0].gif\" alt=\"\" "
except for that the 0 being there means only the last output box is displayed.

None of the other similar lines cause a problem, but as I am looping through an array to display, I need that eveit_$i].gif rather than eveit_0].gif. I could put a switch case for every line, but that'd be rather inefficient with many users.

Any suggestions on how to get around that error? I've tried using {$i} in the code, same error. It really doesn't want me to use a variable there, for some reason. I know $i has a value, if I place echo $i; in my code I get 012345678910 at the top of my page.


One other slightly unrelated question, when the collapsible box is collapsed, there's no title on the bar that the image is on that signifies what is in the box. Is there a way to give the box some header text?
Reply With Quote
  #2  
Old 01-28-2008, 03:37 AM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try to quote out $vbcollapse[collapseimg_359_eveit_0] like this if you can.
PHP Code:
$ocfapidata .= "src=\"".$stylevar[imgdir_button]."/collapse_thead" $vbcollapse[collapseimg_359_eveit_0]. ".gif\" alt=\"\" "
Reply With Quote
  #3  
Old 01-28-2008, 02:21 PM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I changed that line to
PHP Code:
$ocfapidata .= "src=\"".$stylevar[imgdir_button]."/collapse_thead";
$collapsenum "collapseimg_359_eveit_".$ig;
$ocfapidata .= $vbcollapse[$collapsenum]; 
and it got rid of the error. I found the reason the boxes weren't repeating That first line in the code had = rather than .=, which is now fixed, and the page is working fine. I'd still like to have a header on collapsed tbody, though...
Reply With Quote
  #4  
Old 01-28-2008, 02:54 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Argh that is some ugly code, when you are writing a lot of HTML into PHP strings use single quotes that way you don't need to escape every double quote in the HTML.

For example:
PHP Code:
$ocfapidata "<tbody><tr><td class=\"thead\" colspan=\"3\"><a style=\"float:".$stylevar[right]."\" href=\"#top\" ";
// BECOMES:
$ocfapidata '<tbody><tr><td class="thead" colspan="3"><a style="float:'$stylevar['right'] .'" href="#top" '
Doesn't it look so much better?
Reply With Quote
  #5  
Old 01-28-2008, 07:45 PM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fixed my code just for you. Happy? :P

Anyway, have a slight problem with the boxes still. Figure it'd be easier to figure out if I post the whole code block. So here it is:
PHP Code:
$apidata = Array();
for (
$ih 0$ih $numcorps$ih++) {
if (
$ih == 0) { $corp "ocf"; }
for (
$i 0$i < ($num[$corp]); $i++) {
$collapse[$corp] = "collapseimg_359_eveit_".$i;
$collapseb[$corp] = 'collapseimg_359_eveit_'.($i $num[$corp]);

$apidata[$corp] .= '<tbody>';
$apidata[$corp] .= '<tr><td class="thead" colspan="4"><a style=';
$apidata[$corp] .= '"float:'.$stylevar['right'].'" href="#top" ';
$apidata[$corp] .= 'onclick="return toggle_collapse(\'359_eveit_'.$i.'\')">';
$apidata[$corp] .= '<img id="collapseimg_359_eveit_'.$i.'" ';
$apidata[$corp] .= 'src="'.$stylevar['imgdir_button'].'/collapse_thead';
$apidata[$corp] .= $vbcollapse[$collapse[$corp]].'.gif" ';
$apidata[$corp] .= 'alt="" border="0" /></a>';
$apidata[$corp] .= $attr[$corp][$i]['charname'].'</td></tr></tbody><tbody id=';
$apidata[$corp] .= '"collapseobj_359_eveit_'.$i.'" style="';
$apidata[$corp] .= $vbcollapse[collapseobj_359_eveit_'.$i.']">';

$apidata[$corp] .= '<tr>';
$apidata[$corp] .= '<td width="15%" class="alt1"><font color="#FF7700">Skill In Training:</font></td>';
$apidata[$corp] .= '<td width="15%" class="alt1">'.$sit[$corp][$i]['trainname'].' '.$sit[$corp][$i]['trainto'].'</td>';
$apidata[$corp] .= '<td width="55%" class="alt1">'.$sit[$corp][$i]['traindesc'].'</td>';
$apidata[$corp] .= '<td width="15%" class="alt1">'.$sit[$corp][$i]['trainleft'].'</td>';
$apidata[$corp] .= '</tr>';

$apidata[$corp] .= '</tbody>';
}

The output is perfectly fine. Until I decide to collapse any box other than the top one, that is. When I collapse any box other than the first one, the right-aligned collapse image turns into an ugly red X. The image source shows as "http://eve-ocf.com/images/omega359-eve/buttons/collapse_thead_collapsed_collapsed.gif". Not sure where it's getting the second _collapsed from.



Also, I'd like to have _nested_ collapsing boxes. I've tried placing another thead/tbody inside the first box (with a different ID of course), and it opens and closes fine (except for the image glitch). However, if it is open and I close the box it is nested in, the text still shows, if it is closed when I close the box it is nested in, then it stays non-visible. Are nested boxes like this possible within the vB code or do I need to add in more javascript for my own boxes?
Attached Images
File Type: gif closed.GIF (4.2 KB, 0 views)
File Type: gif open.GIF (4.7 KB, 0 views)
Reply With Quote
  #6  
Old 01-29-2008, 01:08 AM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fixed the image issue by moving $vbcollapse[$collapse[$corp]].'.gif" '; to its own line. Still looking for a way to nest collapsible boxes, anybody know how?
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 03:12 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.03734 seconds
  • Memory Usage 2,278KB
  • Queries Executed 14 (?)
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
  • (6)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
  • (2)postbit_attachment
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete