vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   help with IF code (https://vborg.vbsupport.ru/showthread.php?t=234882)

emath 02-03-2010 09:50 AM

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 ?

Marco van Herwaarden 02-03-2010 11:05 AM

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); 


emath 02-03-2010 11:32 AM

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>


Marco van Herwaarden 02-03-2010 11:39 AM

What is the error?

emath 02-03-2010 11:55 AM

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>


Marco van Herwaarden 02-03-2010 12:35 PM

The error should tell you more then only a linenumber.

Also, are you editing the product xml-file directly?

emath 02-03-2010 02:33 PM

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

"Also, are you editing the product xml-file directly?" no .

TheLastSuperman 02-03-2010 03:44 PM

Quote:

Originally Posted by imiviortal (Post 1973982)
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 :D

Marco van Herwaarden 02-04-2010 07:54 AM

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.

emath 02-11-2010 07:15 AM

i am editing the XML file..
and i posted how ive edited it


All times are GMT. The time now is 04:11 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.01275 seconds
  • Memory Usage 1,801KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete