• [MOD] Dropdown options for custom database fields 4 0 5 1
Currently:  

Author Topic: [MOD] Dropdown options for custom database fields  (Read 199391 times)

0 Members and 2 Guests are viewing this topic.

Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.423
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] Dropdown options for custom database fields
« Reply #90 on: May 11, 2008, 07:19:33 PM »

dieses ist in der 1.7.6 nur 1x vorhanden

Hi Harald,

könntest du hier als Anwort die komplette Anleitung für 1.7.6 reinschreiben?
Anschließend setzte ich die in den ersten Post von Vano. Danke!
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: [MOD] Dropdown options for custom database fields
« Reply #91 on: May 12, 2008, 11:41:09 PM »
4images v1.7.6

Step 1

:flag-en: Open members.php
:flag-de: Öffne members.php

:flag-en: search:
:flag-de: suche: 
Code: [Select]
else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
      }

:flag-en: Insert above   
:flag-de: füge darüber ein:

Code: [Select]
elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
        $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }

Step 1.1

:flag-en: search:
:flag-de: suche:

Code: [Select]
else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
      }

:flag-en: Insert above:
:flag-de: füge darüber ein:

Code: [Select]
elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
        $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }


Step 2
:flag-en: Open register.php
:flag-de: Öffne register.php

:flag-en: search:
:flag-de: suche:

Code: [Select]
else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }

:flag-en: Replace with:
:flag-de: ersetze mit:

Code: [Select]
else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }
        elseif ($val[1] == "dropdown") {
          $value = (isset($HTTP_POST_VARS[$key])) ? $HTTP_POST_VARS[$key] : $user_info[$key];
           $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
        }


Step 3
:flag-en: Open includes/functions.php
At the end, above closing ?> insert:

:flag-de: Öffne includes/funktions.php
füge am ende vor ?> folgendes ein

Code: [Select]
function get_dropdown_options($name, $options = array(), $value = "", $multi_dim = 1, $number = 0, $auto = 0, $keypress = 0, $extra = "", $class = "", $i_start = 0, $i_step = 1, $i_stop = 1) {
  $keypress = ($keypress) ? " onkeypress=\"if(window.event.keyCode==13)this.form.submit();\"" : "";
  $auto = ($auto) ? " onchange=\"this.form.submit();\"" : "";
    $dropdown = "<SELECT name=\"".$name."\"".$auto.$keypress." class=\"".(($class) ? $class : "select")."\"".$extra.">\n";
   $i = $i_start;
  if (count($options)) {
    foreach ($options as $key => $val) {
       $what = (($number) ? $i : (($multi_dim) ? $key : $val));
        $dropdown .= "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".preg_replace (array("/{key}/siU", "/{val}/siU", "/{what}/siU", "/{value}/siU"), array($key, $val, $what, $value), $val)."</option>\n";
        $i = $i + $i_step;
     }
  }else{
    for ($i = $i_start; $i <= $i_stop; $i += $i_step) {
        $dropdown .= "<option value=\"".$i."\"".(($value == $i) ? " selected" : "").">".$i."</option>\n";
    }
  }
   $dropdown .= "</select>\n";
  return $dropdown;
}
function get_db_fields_dropdown($key, $val, $value) {
  return get_dropdown_options($key, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]);
}


Step 4
:flag-en: Open admin/admin_functions.php
:flag-de: Öffne admin/admin_functions.php

:flag-en: search:
:flag-de: suche:

Code: [Select]
case "radio":
        show_radio_row($val[0], $field_name, ($value == "") ? 1 : $value);
        break;

:flag-en: Insert below:
:flag-de: füge darunter ein:

Code: [Select]
case "dropdown":
        show_user_dropdown_row($field_name, $val, $value);
        break;

Step 4.1

:flag-en: At the end, above closing ?> insert:

:flag-de: füge am ende vor ?> folgendes ein

Code: [Select]
function show_user_dropdown_row($name, $val, $value = 0){
  echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">".$val[0]."</p></td>\n";
  echo "<td><p>\n";
  echo get_dropdown_options($name, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]);
  echo "</p></td>\n</tr>\n";
}









« Last Edit: June 10, 2008, 12:39:27 AM by Jan-Lukas »
Danke Harald




Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.423
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] Dropdown options for custom database fields
« Reply #92 on: May 13, 2008, 08:21:47 AM »
Thanks, first post edited.
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Tobi.L

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #93 on: June 09, 2008, 07:06:19 PM »
Hallo zusammen,

klasse an dem Ersteller dieser Mod.
Da ich vorhin dabei war krampfhaft nen Dropdown einzubauen, bin ich auf der Suche nach solch einen Mod gewesen und bin fündig geworden. Scheint auch zu laufen, das blöde ist nur das ich kein Englisch, bin überfragt.

Ich möchte etwas folgender maßen:

(Ps.: Eins vorweg, wie man normale User + Imagefelder einfügt weis ich)

Ich möchte ein Dropdown Menü mit Mehrfachauswahl.
Was muss dann für das Dropdown in die d_funktions.. und in die main.php

ich blicke da nicht durch!

Offline nobby

  • 4images Guru
  • *******
  • Posts: 2.873
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #94 on: June 09, 2008, 07:15:47 PM »
Hallo Tobi,

dann würde ich mich mal auf den Hosenboden setzen und Englisch lernen, ohne kommst Du in der heutigen Zeit nicht mehr weit...

Naja, und wenn alle stricke reißen gibt es ja noch den Google-Translator, der ist sehr Hilfreich  :wink:

nobby

Tobi.L

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #95 on: June 09, 2008, 07:45:57 PM »
Ja das ist mir klar,
aber ich komme mir Google auch nicht viel weiter! Ein bisschen Englsich kann ich aber hier blicke ich nicht durch!

Das habe ich z.B in der Editprofil stehen:
Code: [Select]
<select name="user_film" onkeypress="if(window.event.keyCode==13)this.form.submit();" size="5" class="input" multiple>
      <option>keine Angabe</option>
      <option>A-Team</option>
      <option>A Nightmare on Elmstreet</option>
    </select>

Das ist eine Auswahl wo man mehr auf einmal auswählen kann!

Wenn ich z.B A-Team auswähle, dann wird das im Profil angezeigt auch das A Nightmare...

Das steht in der db_function:
Code: [Select]
$additional_user_fields['user_film'] = array($lang['user_film'], "dropdown", 0, array("keineAngabe", "anightmareonelmstreet", "ateam"), 1, 0, 0, 1);
Ich bekomme es nicht hin, wenn ich A-Team und A Nightmare on Elmstreet auswähle, dass beides im Profil angezeigt wird.

Dazu möchte ich das, dass der User im Editprofil sieht was er ausgewählt hat, denn es springt immer auf "keine Angabe" zurück und das heisst, wenn der User nur irgendetwas am Profil ändern, sei es nur die ICQ Nummer, dann ist seine Film Auswahl auch weg!

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Re: [MOD] Dropdown options for custom database fields
« Reply #96 on: June 10, 2008, 12:44:03 AM »
@ Kai, @ Detlef,
Kannst Du bitte im ersten Posting Step. 4.1 editieren ?
natürlich muss das nicht
 
Quote
Open includes/functions.php
At the end, above closing ?> insert:

 Öffne includes/funktions.php
füge am ende vor ?> folgendes ein

heissen, denn wird ja in der admin/admin_functions.php geändert  :wink:

mein Posting hab ich schon editiert

Danke
Danke Harald




Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.423
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] Dropdown options for custom database fields
« Reply #97 on: June 10, 2008, 09:47:12 AM »
@ Jan-Lukas: Ok, 1st post edited.
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Tobi.L

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #98 on: June 10, 2008, 11:12:21 PM »
Ja das ist mir klar,
aber ich komme mir Google auch nicht viel weiter! Ein bisschen Englsich kann ich aber hier blicke ich nicht durch!

Das habe ich z.B in der Editprofil stehen:
Code: [Select]
<select name="user_film" onkeypress="if(window.event.keyCode==13)this.form.submit();" size="5" class="input" multiple>
      <option>keine Angabe</option>
      <option>A-Team</option>
      <option>A Nightmare on Elmstreet</option>
    </select>

Das ist eine Auswahl wo man mehr auf einmal auswählen kann!

Wenn ich z.B A-Team auswähle, dann wird das im Profil angezeigt auch das A Nightmare...

Das steht in der db_function:
Code: [Select]
$additional_user_fields['user_film'] = array($lang['user_film'], "dropdown", 0, array("keineAngabe", "anightmareonelmstreet", "ateam"), 1, 0, 0, 1);
Ich bekomme es nicht hin, wenn ich A-Team und A Nightmare on Elmstreet auswähle, dass beides im Profil angezeigt wird.

Dazu möchte ich das, dass der User im Editprofil sieht was er ausgewählt hat, denn es springt immer auf "keine Angabe" zurück und das heisst, wenn der User nur irgendetwas am Profil ändern, sei es nur die ICQ Nummer, dann ist seine Film Auswahl auch weg!

Ich blicke da nicht durch!

Offline sidharth186

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #99 on: August 10, 2008, 11:59:27 AM »
Hi !

Please help me ....I am using version 1.7.6

I have added a custom field 'User Type' in the Database and have also created a Dropdown for that using your MOD .

But the only problem that I am facing is :

In the ACP the Edit User - User Type shows the dropdown but does not show the value that was previously selected....

I mean if the User Type was Photographer when the account was created, the ACP will still show the dropdown starting from '----' , 'General', 'Photographer'

Also kindly tell me how to search for the users when I go to Edit Users in ACP , on the basis of this new custom field , i.e., 'User Type' as that field is currently not visible in the search form.

I hope you can solve this ....

I will be highly grateful to you if you can help me out on this ...

Thanks a lot
« Last Edit: August 10, 2008, 06:38:51 PM by V@no »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #100 on: August 10, 2008, 06:47:07 PM »
I'd guess you missed step 4...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline sidharth186

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #101 on: August 11, 2008, 09:24:03 PM »
I'd guess you missed step 4...

Thanks V@no !!!
Its working now ...
Can you pls suggest some MOD for getting this custom field in the User Search also......I mean when we go to Edit Users in ACP, can we get this additional field there to search on its basis?

Thanks again for your timely reply

Offline runway27r

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Wings Over Philadelphia
Re: [MOD] Dropdown options for custom database fields
« Reply #102 on: October 01, 2008, 07:28:29 PM »
Is there a way to get this MOD to work for Upload Fields? My needs are for that rather than user info.

THX
Paul

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #103 on: October 01, 2008, 07:38:36 PM »
... the dropdown fields are also working on uploadform ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: [MOD] Dropdown options for custom database fields
« Reply #104 on: October 22, 2008, 05:52:38 PM »
Irgendwee habe ich da ein Problem, das was im Dropdown ausgewählt wurde, wird nicht angezeigt!
Folgendes habe ich gemacht:
--
Somehow, I have a problem because that is what the drop has been selected, will not be displayed!
I have done the following:

Open:
includes/db_field_definitions.php
Im Add:
$additional_user_fields['image_prefix'] = array($lang['image_prefix'], "dropdown"0, array("prefix wurde nicht geaehlt""4images 1.7.6""Phpkit 1.6.0.3""Phpkit 1.6.1""Phpkit 1.6.4""SMF 1.1.5""SMF 1.1.6""SMF 2.0 Beta""WBB 3""WBB 2" "WBB 3 Lite""Wbb 2 Lite""Normal"), 0150);

Open:
lang/mylang/main.php
Im add:
$lang['image_prefix'] = "Prefix der Kategorie";

Open:
templates7mytemplate/member_uploadform,html
Im Added:
<select name="image_prefix" onkeypress="if(window.event.keyCode==13)this.form.submit();" /> 
    <
option value="5">prefix wurde nicht geaehlt</option
    <
option value="6">4images 1.7.6</option
    <
option value="7">Phpkit 1.6.0.3</option
    <
option value="8">Phpkit 1.6.1</option
    <
option value="9">Phpkit 1.6.4</option
    <
option value="10">SMF 1.1.5</option
    <
option value="11">SMF 1.1.6</option
    <
option value="12">SMF 2.0 Beta</option
    <
option value="13">WBB 3</option
    <
option value="14">WBB 2</option
    <
option value="15">WBB 3 Lite</option
    <
option value="16">WBB 2 Lite</option
    <
option value="17">Normal</option
  </
select>

This is in Uploadform Displayed!!!

Open;:
templates/mytemplate/details.html
Im Added:
{image_prefix_dropdown}

And in my phpmyadmin:
Im added:
ALTER TABLE `4images_imagesADD `image_prefixVARCHAR255 NOT NULL

Ich wähle beim Upload den gewünschten Prefix aus, doch in der Detailansicht wird es nicht angezeigt. Was ist denn falsch gelaufen?
--
I choose when you upload the desired prefix, but in the details view, it will not be displayed. What is wrong?