View Single Post
  #1  
Old 05-04-2012, 07:57 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Unexpected T_STRING in custom plugin ?

Hello

(Sorry for my bad english)
I wrote a custom plugin and i have a error when trying to display an array using vb:each (unexpected T_STRING in class_core.php). If i don't register the array, there is no error, if i don't try to display the array there is no error, and my code perfectly run outside of VB.

So in my plugin i create an array, needed to create the second array :
PHP Code:
        $rescue = array();
        while (
$donnees $db->fetch_array($req_rescue)){
            
$rescue_id intval($donnees['id']);
            if(
$donnees['cherchable'] = 1){$rescue[$rescue_id] = $donnees['nom'];}
            else{
$rescue[$rescue_id] = 0;} 
            unset(
$rescue_id);
        }
        unset(
$donnees);
        
$db->free_result($req_rescue);
        
        
$tableau_lieux = array();
        while (
$donnees $db->fetch_array($req_liste)){
            
$id_lieu $donnees['a13'];
            if(
$donnees['a13'] != 0){
                if(!
array_key_exists($id_lieu$tableau_lieux)){
                    
$tableau_lieux[$id_lieu] = $rescue[$id_lieu];
                }
            }
            unset(
$id_lieu);
        }
        unset(
$donnees);
        
$db->free_result($req_liste); 
Prepare the array and registering it, to be used in the template recherche_adop_fd which will be displayed in 'forumdisplay' :

PHP Code:
        //On enl?ve les valeurs valant 0 (non cherchable) et on tri
        
unset($tableau_lieux[array_search(0$tableau_lieux)]);
        
asort($tableau_lieux);
        
$newTemplate vB_Template::create('recherche_adop_fd'); 
        
$newTemplate->register('tableau_lieux'$tableau_lieux);
        
$recherche_adop_fd$newTemplate->render();   

        
$placer_recherche '<!--recherche_adop-->'

        
$vbulletin->templatecache['FORUMDISPLAY'] = str_replace($placer_recherche,$placer_recherche.$recherche_adop_fd$vbulletin->templatecache['FORUMDISPLAY']); 
And my vb:each from recherche_adop_fd :
PHP Code:
            <vb:each from="tableau_lieux" key="id" value="valeur">
            <
option value="{vb:var id}">{vb:var valeur}</option>
            </
vb:each
If that can help you, here is the tableau_lieu array output using a print_r :
Code:
Array
(
    [372] => 01 - Ain
    [373] => 02 - Aisne
    [374] => 03 - Allier
    [375] => 04 - Alpes-de-Haute-Provence
    [376] => 05 - Hautes-Alpes
    [377] => 06 - Alpes-Maritimes
    [378] => 07 - Ard?che
    [379] => 08 - Ardennes
    [380] => 09 - Ari?ge
    [381] => 10 - Aube
    [382] => 11 - Aude
    [383] => 12 - Aveyron
    [384] => 13 - Bouches-du-Rh?ne
    [385] => 14 - Calvados
    [386] => 15 - Cantal
    [387] => 16 - Charente
    [388] => 17 - Charente-Maritime
    [389] => 18 - Cher
    [391] => 20 - Corse
    [392] => 21 - C?te-d'Or
    [393] => 22 - C?tes-d'Armor
    [395] => 24 - Dordogne
    [396] => 25 - Doubs
    [397] => 26 - Dr?me
    [398] => 27 - Eure
    [399] => 28 - Eure-et-Loir
    [400] => 29 - Finist?re
    [401] => 30 - Gard
    [402] => 31 - Haute-Garonne
    [403] => 32 - Gers
    [404] => 33 - Gironde
    [405] => 34 - H?rault
    [406] => 35 - Ille-et-Vilaine
    [407] => 36 - Indre
    [408] => 37 - Indre-et-Loire
    [409] => 38 - Is?re
    [410] => 39 - Jura
    [411] => 40 - Landes
    [412] => 41 - Loir-et-Cher
    [413] => 42 - Loire
    [414] => 43 - Haute-Loire
    [415] => 44 - Loire-Atlantique
    [416] => 45 - Loiret
    [417] => 46 - Lot
    [418] => 47 - Lot-et-Garonne
    [420] => 49 - Maine-et-Loire
    [421] => 50 - Manche
    [422] => 51 - Marne
    [423] => 52 - Haute-Marne
    [425] => 54 - Meurthe-et-Moselle
    [426] => 55 - Meuse
    [427] => 56 - Morbihan
    [428] => 57 - Moselle
    [429] => 58 - Ni?vre
    [430] => 59 - Nord
    [431] => 60 - Oise
    [432] => 61 - Orne
    [433] => 62 - Pas-de-Calais
    [434] => 63 - Puy-de-D?me
    [435] => 64 - Pyr?n?es-Atlantiques
    [436] => 65 - Hautes-Pyr?n?es
    [437] => 66 - Pyr?n?es-Orientales
    [438] => 67 - Bas-Rhin
    [439] => 68 - Haut-Rhin
    [440] => 69 - Rh?ne
    [441] => 70 - Haute-Sa?ne
    [442] => 71 - Sa?ne-et-Loire
    [443] => 72 - Sarthe
    [444] => 73 - Savoie
    [445] => 74 - Haute-Savoie
    [446] => 75 - Paris
    [447] => 76 - Seine-Maritime
    [448] => 77 - Seine-et-Marne
    [449] => 78 - Yvelines
    [450] => 79 - Deux-S?vres
    [451] => 80 - Somme
    [452] => 81 - Tarn
    [453] => 82 - Tarn-et-Garonne
    [454] => 83 - Var
    [455] => 84 - Vaucluse
    [456] => 85 - Vend?e
    [457] => 86 - Vienne
    [459] => 88 - Vosges
    [460] => 89 - Yonne
    [461] => 90 - Territoire de Belfort
    [462] => 91 - Essonne
    [463] => 92 - Hauts-de-Seine
    [464] => 93 - Seine-Saint-Denis
    [465] => 94 - Val-de-Marne
    [466] => 95 - Val-d'Oise
    [468] => Belgique
    [470] => Canada
    [472] => Non renseign?
    [467] => Outre-mer
)
Thank you a lot.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01272 seconds
  • Memory Usage 1,820KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete