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 02-03-2010, 09:50 AM
emath emath is offline
 
Join Date: Sep 2008
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default help with IF code

hey there,

i wanna do some code in a mode which shows my user gourps at the end of the index page.

there is the rows :

PHP Code:

            
<phpcode><![CDATA[if (THIS_SCRIPT == "index" and $vbulletin->options['ugl_onoff'])
{
$activeusers2 .= '<br />';
$userbuls split(','$vbulletin->options['sirala']);
foreach(
$userbuls AS $userbul) {

$activeusers2 .= $vbulletin->usergroupcache["$userbul"]['opentag'] . $vbulletin->usergroupcache["$userbul"]['title'] .  ' >> '  $vbulletin->usergroupcache["$userbul"]['closetag'];
}
$activeusers '<b>'.$activeusers2 .'</b><br /><br />'$activeusers;
}]]></
phpcode
now i want that it will do the characters ">>" to every user group but the last...

so it will have an "if" that will check like if(!$last){ '>>' } i just tried to do that alot with no succeed any help ?
Reply With Quote
  #2  
Old 02-03-2010, 11:05 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Instead of add a string to $activeusers2 (string) in a loop, make $activeusers2 an array and add only the open/closetag and the grouptitle to this array. Now once the loop is finished, use implode() to convert the array to a string adding the seperators you want.

Example:
PHP Code:
$activeusers2 = array();
$userbuls split(','$vbulletin->options['sirala']); 
foreach(
$userbuls AS $userbul)
{
 
$activeusers2[] = vbulletin->usergroupcache["$userbul"]['opentag'] . $vbulletin->usergroupcache["$userbul"]['title'] . $vbulletin->usergroupcache["$userbul"]['closetag']; 
}
$activeusersstring implode(">>"$activeusers2); 
Reply With Quote
  #3  
Old 02-03-2010, 11:32 AM
emath emath is offline
 
Join Date: Sep 2008
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i getting an code error when i doing as u said, thats the all code :

PHP Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="usergrouplegend" active="1">
    <title>מקרא קבוצות -</title>
    <description>מוסיף מקרא קבוצות בעמוד הראשי</description>
    <version>2.0.0</version>
    <url />
    <versioncheckurl />
    <dependencies>
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title><![CDATA[מקרא קבוצות - J2Gaming.com (תורגם ע"י vBHeb.com)]]></title>
            <hookname>forumhome_complete</hookname>
            <phpcode><![CDATA[if (THIS_SCRIPT == "index" and $vbulletin->options['ugl_onoff'])
{
$activeusers2 .= '<br />';
$userbuls = split(',', $vbulletin->options['sirala']);
foreach($userbuls AS $userbul) {

$activeusers2 .= $vbulletin->usergroupcache["$userbul"]['opentag'] . $vbulletin->usergroupcache["$userbul"]['title']   . $vbulletin->usergroupcache["$userbul"]['closetag'] .  ' >> ';
}
$activeusers = '<b>'.$activeusers2 .'</b><br /><br />'. $activeusers;
}]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
        <phrasetype name="vBulletin Settings" fieldname="vbsettings">
            <phrase name="setting_sirala_desc" date="1185364479" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[כתוב את מספרי הקבוצות לפי הסדר שבו אתה רוצה שהן יוצגו במקרא המשתמשים. <br /> הפרד באמצעות פסיק (,).]]></phrase>
            <phrase name="setting_sirala_title" date="1185364479" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[סדר הצגת הקבוצות]]></phrase>
            <phrase name="setting_ugl_onoff_desc" date="1185275296" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[האם ברצונך להציג את מקרא הקבוצות?]]></phrase>
            <phrase name="setting_ugl_onoff_title" date="1185275296" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[הצג מקרא קבוצות?]]></phrase>
            <phrase name="settinggroup_ugl" date="1185275204" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[מקרא קבוצות]]></phrase>
        </phrasetype>
    </phrases>
    <options>
        <settinggroup name="ugl" displayorder="65535">
            <setting varname="ugl_onoff" displayorder="10">
                <datatype>boolean</datatype>
                <optioncode>yesno</optioncode>
                <defaultvalue>1</defaultvalue>
            </setting>
            <setting varname="sirala" displayorder="20">
                <datatype>free</datatype>
                <defaultvalue>6,5,7,2</defaultvalue>
            </setting>
        </settinggroup>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
</product>
Reply With Quote
  #4  
Old 02-03-2010, 11:39 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the error?
Reply With Quote
  #5  
Old 02-03-2010, 11:55 AM
emath emath is offline
 
Join Date: Sep 2008
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it says its on line 11 nothing more, thats the code after ive edited as u said :

PHP Code:

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="usergrouplegend" active="1">
    <title>מקרא קבוצות -</title>
    <description>מוסיף מקרא קבוצות בעמוד הראשי</description>
    <version>2.0.0</version>
    <url />
    <versioncheckurl />
    <dependencies>
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title><![CDATA[מקרא קבוצות - J2Gaming.com (תורגם ע"י vBHeb.com)]]></title>
            <hookname>forumhome_complete</hookname>
            <phpcode><![CDATA[if (THIS_SCRIPT == "index" and $vbulletin->options['ugl_onoff'])
{
$activeusers2 = array();
$userbuls = split(',', $vbulletin->options['sirala']);
foreach($userbuls AS $userbul) {

 $activeusers2[] = vbulletin->usergroupcache["$userbul"]['opentag'] . $vbulletin->usergroupcache["$userbul"]['title'] . $vbulletin->usergroupcache["$userbul"]['closetag']; 
}
$activeusersstring=  implode(">>", $activeusers2);
$activeusers =$activeusersstring .'</b><br /><br />'. $activeusers;
}]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
        <phrasetype name="vBulletin Settings" fieldname="vbsettings">
            <phrase name="setting_sirala_desc" date="1185364479" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[כתוב את מספרי הקבוצות לפי הסדר שבו אתה רוצה שהן יוצגו במקרא המשתמשים. <br /> הפרד באמצעות פסיק (,).]]></phrase>
            <phrase name="setting_sirala_title" date="1185364479" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[סדר הצגת הקבוצות]]></phrase>
            <phrase name="setting_ugl_onoff_desc" date="1185275296" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[האם ברצונך להציג את מקרא הקבוצות?]]></phrase>
            <phrase name="setting_ugl_onoff_title" date="1185275296" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[הצג מקרא קבוצות?]]></phrase>
            <phrase name="settinggroup_ugl" date="1185275204" username="Jet.HaCkR - J2Gaming.com" version="2.0.0"><![CDATA[מקרא קבוצות]]></phrase>
        </phrasetype>
    </phrases>
    <options>
        <settinggroup name="ugl" displayorder="65535">
            <setting varname="ugl_onoff" displayorder="10">
                <datatype>boolean</datatype>
                <optioncode>yesno</optioncode>
                <defaultvalue>1</defaultvalue>
            </setting>
            <setting varname="sirala" displayorder="20">
                <datatype>free</datatype>
                <defaultvalue>6,5,7,2</defaultvalue>
            </setting>
        </settinggroup>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
</product>
Reply With Quote
  #6  
Old 02-03-2010, 12:35 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The error should tell you more then only a linenumber.

Also, are you editing the product xml-file directly?
Reply With Quote
  #7  
Old 02-03-2010, 02:33 PM
emath emath is offline
 
Join Date: Sep 2008
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just please tell me how to do an "if" as i explained before plz...

"Also, are you editing the product xml-file directly?" no .
Reply With Quote
  #8  
Old 02-03-2010, 03:44 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by imiviortal View Post
just please tell me how to do an "if" as i explained before plz...


"Also, are you editing the product xml-file directly?" no .
Marco is trying to help you do it a better way so bare with him and let him post so it can be helpful to you
Reply With Quote
  #9  
Old 02-04-2010, 07:54 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you are not editing the xml-file, then please post only the code of the plugin that is causing the problems, this makes it a lot easier to find any errors.
Reply With Quote
  #10  
Old 02-11-2010, 07:15 AM
emath emath is offline
 
Join Date: Sep 2008
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i am editing the XML file..
and i posted how ive edited it
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 07:52 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.04463 seconds
  • Memory Usage 2,296KB
  • 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
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete