PDA

View Full Version : help with IF code


emath
02-03-2010, 09:50 AM
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 :



<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:
$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 :



<?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 :



<?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
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

kh99
02-11-2010, 12:31 PM
You're missing a '$' from the part you edited, before the first 'vbulletin->'.

Should be:

$activeusers2[] = $vbulletin->usergroupcache["$userbul"]['opentag'] . $vbulletin->usergroupcache["$userbul"]['title'] . $vbulletin->usergroupcache["$userbul"]['closetag'];

emath
02-11-2010, 12:55 PM
thanks alot now its working great !! :)

Marco van Herwaarden
02-15-2010, 11:01 AM
PS You should not be editing the XML-file directly.