Author Topic: [MOD] Individual Radio-button caption instead yes or no  (Read 19329 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[MOD] Individual Radio-button caption instead yes or no
« on: January 24, 2010, 10:39:39 AM »
Hi!

1.) search in admin/functions.php:

function show_radio_row($title$name$value 1) {
  global 
$HTTP_POST_VARS$lang;
  if (isset(
$HTTP_POST_VARS[$name])) {
    
$value $HTTP_POST_VARS[$name];
  }
  echo 
"<tr class=\"".get_row_bg()."\">\n";
  echo 
"<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>";
  echo 
"<input type=\"radio\" name=\"$name\" value=\"1\"";
  if (
$value == 1) {
    echo 
" checked=\"checked\"";
  }
  echo 
"> ".$lang['yes']."&nbsp;&nbsp;&nbsp;\n";
  echo 
"<input type=\"radio\" name=\"".$name."\" value=\"0\"";
  if (
$value != 1) {
    echo 
" checked=\"checked\"";
  }
  echo 
"> ".$lang['no']." ";
  echo 
"</p></td>\n</tr>";
}

replace:

function show_radio_row($title$name$value 1$yes="",$no="") {
  global 
$HTTP_POST_VARS$lang;
  if (isset(
$HTTP_POST_VARS[$name])) {
    
$value $HTTP_POST_VARS[$name];
  }
  if (isset(
$HTTP_POST_VARS[$yes])) {  
    
$yes $HTTP_POST_VARS[$yes];
  }
  if(empty(
$yes)){
    
$yes$lang['yes'];
  }
  if (isset(
$HTTP_POST_VARS[$no])) {  
    
$no =$HTTP_POST_VARS[$no];
  }
  elseif(empty(
$no)){
    
$no$lang['no'];
  }
  echo 
"<tr class=\"".get_row_bg()."\">\n";
  echo 
"<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>";
  echo 
"<input type=\"radio\" name=\"$name\" value=\"1\"";
  if (
$value == 1) {
    echo 
" checked=\"checked\"";
  }
  echo 
"> ".$yes."&nbsp;&nbsp;&nbsp;\n";
  echo 
"<input type=\"radio\" name=\"".$name."\" value=\"0\"";
  if (
$value != 1) {
    echo 
" checked=\"checked\"";
  }
  echo 
"> ".$no." ";
  echo 
"</p></td>\n</tr>";
}


search:

show_radio_row
($val[0], $field_name, ($value == "") ? $value);

and replace:

show_radio_row
($val[0], $field_name, ($value == "") ? $value$val[3],$val[4]);


in includes\db_field_definitions.php can you now instead:
example:

$additional_image_fields
['photographer'] = array($lang['photographer'], "radio"1);


this write:

$additional_image_fields
['photographer'] = array($lang['photographer'], "radio"1,"choice1","choice2");



mfg Andi
« Last Edit: January 24, 2010, 05:47:59 PM by Rembrandt »

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [TUT]Individual Radio-button caption instead yes or no
« Reply #1 on: January 24, 2010, 02:35:51 PM »
You are the MAN! Very good work. I like it. (I already start using it om my site. I thank you man.

I have another question: Can you take this tweak to a higher level to use it also for RADIO GROUP (More than 2 choices)? I am thinking about a new field name: radio_group. Something like the dropdown mod of V@no.

Thanks in advance:)
 
« Last Edit: January 24, 2010, 02:54:46 PM by cruxy »

Rembrandt

  • Guest
Re: [TUT]Individual Radio-button caption instead yes or no
« Reply #2 on: January 24, 2010, 02:52:51 PM »
..
A small correction:.......
Thanks for the correction.. arrrgh ..my english

Quote
I have another question: ...]RADIO GROUP[/b] (More than 2 choices)? ......
puhh ...I have to think about it....
 
mfg Andi

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: [TUT]Individual Radio-button caption instead yes or no
« Reply #3 on: January 24, 2010, 02:56:38 PM »
No problem Andy. Many thanks in advance :D

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.807
  • I ♥ 4I
    • View Profile
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #4 on: March 01, 2010, 12:08:35 PM »
Was genau ist das?
Muss man dann nurnoch in der db_field_definitions.php die Angaben angeben?

Rembrandt

  • Guest
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #5 on: March 01, 2010, 05:25:03 PM »
Muss man dann nurnoch in der db_field_definitions.php die Angaben angeben?
ja.. ,ist eine individuelle buttonbeschríftung anstatt immer nur ja und nein, kannst du irgend etwas anderes reinschreiben.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.807
  • I ♥ 4I
    • View Profile
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #6 on: March 01, 2010, 11:34:55 PM »
Hey, superklasse.
Wie kann man das mit den Sprachvariablen vereinbaren? Meine Gallerie hat 5 verschiedene Sprachen. Kann man irgendwie diese von der main.php auslesen?

Geht das auf dierser Art und Weise?

$lang['image_field']

main.php
$lang['image_field_array'] = array("text1""text2");

de_field....php
$additional_image_fields['photographer'] = array($lang['photographer'], "radio"1,$lang['image_field_array']);

??

Rembrandt

  • Guest
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #7 on: March 02, 2010, 07:48:32 AM »
diese modifikation hat nur auswirkung auf den adminbereich, in deinen templates kannst du die buttons ja beschriften wie du möchtest.

in der db_definitions.php:
$additional_user_fields['user_test'] = array($lang['user_test'], "radio"1,$lang['blub'],$lang['blabla']);


in der lang/main.php:

$lang
['user_test'] = "user test feld";
$lang['blub']="irgend_etwas";
$lang['blabla']="was_anderes";


mfg Andi

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.807
  • I ♥ 4I
    • View Profile
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #8 on: March 20, 2010, 01:49:49 PM »
Danke dir.

Ist es auch möglich, dass das was man anklickt auch ausgegeben wird?

Wenn ich es wie folgt mache:
$additional_image_fields['image_os'] = array($lang['image_os'], "radio"0,"Test","Test2");

Wenn ich Test auswähle wird auf der Seite "1" ausgegeben
Wenn ich Test2 auswähle, wird nichts ausgegeben

Kann man das nicht so machen, dass dann "Test" oder "Test2" oder auch "Test3" ausgegeben wird?
$additional_image_fields['image_os'] = array($lang['image_os'], "radio"0,"Test","Test2","Test3","Test4"); .....


Rembrandt

  • Guest
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #9 on: March 20, 2010, 02:24:58 PM »
..

Ist es auch möglich, dass das was man anklickt auch ausgegeben wird?
...
Wenn ich Test auswähle wird auf der Seite "1" ausgegeben
Wenn ich Test2 auswähle, wird nichts ausgegeben

nichts wird eigentlich nicht ausgegeben,  "0" wäre richtig.

diese änderung hat ja eigentlich keine funktion, sondern ist nur zur individuellen beschrifung da.

ich denke mal das es besser wäre eine neue funktion zu schreiben die eine gruppe von buttons ermöglicht.

das die beschriftung ausgegeben wird halte ich nicht für sinnvoll, die flexibilität wäre sehr eingeschrenkt, als bspl. wenn du die auswahl "test3" wählen würdest:

 in der datenbank kannst du mit "test3" nicht rechnen..
 oder in php, das geht nicht..

 if (test3 > test1) dann mache dies oder das

wenn du aber "test3" den wert 3 zuweist dann kannst du damit alles mögliche anstellen:
 das funktioniert...

 if (3>1) dann mache dies oder das

EDIT: das was du möchtest,brauchst.. wären checkboxen..

mfg Andi

  
« Last Edit: March 20, 2010, 02:39:22 PM by Rembrandt »

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.807
  • I ♥ 4I
    • View Profile
Re: [MOD] Individual Radio-button caption instead yes or no
« Reply #10 on: March 20, 2010, 02:55:16 PM »
Checkboxen wäre das genau das richtige, ja!