Author Topic: Add new field top.php  (Read 8869 times)

0 Members and 1 Guest are viewing this topic.

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Add new field top.php
« on: February 12, 2008, 07:53:47 PM »
hi

how cant add new fields in top.php

my change in top.php

modify top.php , new field {user_hobbies}

Code: [Select]
// Votes
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_rating, i.image_votes, c.cat_name".get_user_table_field(", u.", "user_name")." ".get_user_table_field(", u.", "user_email")."  ".get_user_table_field(", u.", "user_homepage")." ".get_user_table_field(", u.", "user_hobbies").", i.image_thumb_file

add this

Code: [Select]
$register_array['image_votes_hobbies_'.$i] .format_text($top_list[$i][$user_table_fields['user_hobbies']]);

add this

Code: [Select]
$register_array['image_votes_hobbies_'.$i] = "--";
template/my_template/top.html

add this

Code: [Select]
{lang_user_hobbies} {if user_hobbies}{image_votes_hobbies_1}{endif user_hobbies}
What is wrong or missing in AMENDED,
I taught in the profile data, but not in top.php

thank
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Add new field top.php
« Reply #1 on: February 13, 2008, 03:18:38 AM »
In top.php file,

find:

Code: [Select]
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");

add after:

Code: [Select]
$additional_sql = "";
if (isset($additional_image_fields) && is_array($additional_image_fields) && !empty($additional_image_fields)) {
   foreach ($additional_image_fields as $key => $val) {
      $additional_sql .= ", i." . $key;
   }
}
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
   foreach ($additional_user_fields as $key => $val) {
      $additional_sql .= ", u." . $key;
   }
}

After each:

Code: [Select]
".get_user_table_field(", u.", "user_name")."

(in SELECT line) - replace :

Code: [Select]
".get_user_table_field(", u.", "user_name") . $additional_sql . "

at end.

This:

Code: [Select]
$register_array['image_votes_hobbies_'.$i] .format_text($top_list[$i][$user_table_fields['user_hobbies']]);

Is no $user_table_fields. Is additional user fields so - like this:

Code: [Select]
$register_array['image_votes_hobbies_'.$i] .format_text($top_list[$i]['user_hobbies']);

Before each:

Code: [Select]
}
  else {
    $register_array['image_xxxx_'.$i] = "--";
    $register_array['image_xxxx_user_'.$i] = "--";
    $register_array['image_xxxx_cat_'.$i] = "--";
    $register_array['image_xxxx_number_'.$i] = "--";

(Note: xxxx is mean each category you see. E.g - votes, hits, downloads).

Add:

Code: [Select]
if (isset($additional_image_fields) && is_array($additional_image_fields) && !empty($additional_image_fields)) {   
    foreach ($additional_image_fields as $key => $val) {
      $register_array['image_xxxx'.$key_.$i] = (!empty($top_list[$i][$key])) ? format_text(trim($top_list[$i][$key]), 1) : REPLACE_EMPTY;
      $register_array['lang_'.$key] = $val[0];
    }   
}
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {   
    foreach ($additional_user_fields as $key => $val) {
      $register_array['image_xxxx'.$key_.$i] = (!empty($top_list[$i][$key])) ? format_text(trim($top_list[$i][$key]), 1) : REPLACE_EMPTY;
      $register_array['lang_'.$key] = $val[0];
    }   
}

After you paste last step, replace each xxxx for each cat name of top (e.g: rating, hits, downloads) .

Now, is possible for use additional image fields and additional user fields with $register_array in top page and use in template. ;)

Finish.
« Last Edit: February 13, 2008, 06:05:17 AM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Add new field top.php
« Reply #2 on: February 13, 2008, 06:05:29 AM »
I edit last step in post.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Re: Add new field top.php
« Reply #3 on: February 13, 2008, 06:36:04 AM »
hi

not working

files creates and modify

in db_field_definitions.php create this

Quote
$additional_user_fields['user_hobbies'] = array($lang['user_hobbies'], "text", 0);

in db create

Quote
ALTER TABLE `4images_users` CHANGE `user_aficiones` `user_aficiones` VARCHAR(255) NOT NULL


in member.php modify this and add

before

Quote
"user_homepage" => $user_homepage,

add this

Quote
"user_hobbies" => $user_hobbies,

before this

Quote
$user_email = (isset($HTTP_POST_VARS['user_email'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_email'])) : "";

add

Quote
$user_hobbies = (isset($HTTP_POST_VARS['user_hobbies'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_hobbies'])) : "";

before

Quote
$user_name = $user_info['user_name'];
  if (!$update_process) {

add this

Quote
$user_hobbies = $user_info['user_hobbies'];

in this line

Quote
$site_template->register_vars(array(
    "user_name" => format_text(stripslashes($user_name), 2),

before add

Quote
"user_hobbies" => format_text(stripslashes($user_hobbies), 2),

in register_form.html add this

Quote
<tr>
            <td class="row1" valign="top"><b>{lang_user_hobbies}</b></td>
            <td class="row1">
              <TEXTAREA name="user_hobbies" cols="23" rows="5" class="input" />{user_hobbies}</textarea>            </td>
          </tr>

member_profile.html add this

Quote
<tr>
            <td class="row1" valign="top"><b>{lang_user_hobbies}</b></td>
            <td class="row1">
              {user_hobbies}            </td>
          </tr>

NOTE: this result no problem, show result in line.

member_editprofile.html add this

Quote
<tr>
            <td class="row1" valign="top"><b>{lang_user_aficiones}</b></td>
            <td class="row1">
              <TEXTAREA name="user_aficiones" cols="23" rows="5" class="input" />{user_aficiones}</textarea>            </td>
          </tr>

I made all my changes in top.php by which I indicated beam and your answer and continues without showing any result, either in details.php also teaches anything,

thank









Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Add new field top.php
« Reply #4 on: February 13, 2008, 01:07:18 PM »
You say member.php and show all step but topic is say top.php and show no step and say is no work. :?
Where is step for top.php (and top.html) you add   :?:
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Re: Add new field top.php
« Reply #5 on: February 13, 2008, 07:05:18 PM »
hi

Apologized for confundirte with these steps, the message written above, it is because I am changing the register_form.html with more fields and one of them is {user_hobbies}

 I would like it to appear in details.php in top.php that this changed with image and {user_email} , { user_homepage} as more data, and other more changes in member.php are to add new fields in the gallery.

The write because they are all changes you make to create the {user_hobbies} field,

the profile shows me all the details of the fields that I have added to the gallery, but in top.php details.php shows or anything, so I top.php is interested in top.html display data {user_hobbies}

thank
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Add new field top.php
« Reply #6 on: February 14, 2008, 04:33:50 AM »
Quote
I would like it to appear in details.php

Ok so use this: http://www.4homepages.de/forum/index.php?topic=19297.0

Quote
in top.php that this changed with image and {user_email}

With code I use before here ... replace all xxxx with each ref (rating, hits, downloads, votes). In template, use: {image_xxxx_your_field_name_number}

xxxx = replace with ref (e.g: rating, hits, downloads, votes).
your_field_name = your add image / user field you add in includes/db_field_definitions.php file.
number = number is same way for top.html file (1 to 10 - default 4images value).

Quote
and other more changes in member.php are to add new fields in the gallery.

No need for edit member.php file for this ... save time by add user / image field in includes/db_field_definitions.php file and use tag in template (is work same for register_form.html, member_profile.html, member_editprofile.html). ;)

Quote
The write because they are all changes you make to create the {user_hobbies} field,

And ... change of what ? Is do for change ?

Quote
he profile shows me all the details of the fields that I have added to the gallery, but in top.php details.php shows or anything, so I top.php is interested in top.html display data {user_hobbies}

If for {user_hobbies}, for top.php file, try: {image_xxxx_user_hobbies_number} after add my tweak. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Re: Add new field top.php
« Reply #7 on: February 14, 2008, 05:28:20 AM »
hi

try with you changer in top.php and change in member.php for this

http://translate.google.com/translate?u=http%3A%2F%2Fwww.4homepages.de%2Fforum%2Findex.php%3Ftopic%3D15362.msg82440%23msg82440&langpair=es%7Cen&hl=es&ie=UTF-8

All changes and had done before, and had added new fields to top.php, but were fields such as those in  {image_description} , {image_keyword} , {user_email}, {user_homepages} fields that already exist in the gallery, but not new, why they need help in order to view results in top.php

You comment as I went once made changes

i see

edit details.php ****SOLVED*****


 change in top.php

Quote
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$additional_sql = "";
if (isset($additional_image_fields) && is_array($additional_image_fields) && !empty($additional_image_fields)) {
   foreach ($additional_image_fields as $key => $val) {
      $additional_sql .= ", i." . $key;
   }
}
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
   foreach ($additional_user_fields as $key => $val) {
      $additional_sql .= ", u." . $key;
   }
}

// Rating

Quote
// Votes
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_rating, i.image_votes, c.cat_name".get_user_table_field(", u.", "user_name") .$additional_sql ." ".get_user_table_field(", u.", "user_email")."  ".get_user_table_field(", u.", "user_homepage").", i.image_thumb_file
        FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
        $cat_match_sql
        ORDER BY i.image_votes DESC, i.image_name ASC
        LIMIT 10";

Quote
$register_array['image_votes_thumb_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img class=\"pic\" src=\"data/thumbnails/".$top_list[$i]['cat_id']."/".$top_list[$i]['image_thumb_file']."\" width=\"150\" height=\"170\" border=\"0\" alt=\"\" />";
   $register_array['image_votes_hobbies_'.$i] .format_text($top_list[$i]['user_hobbies']);

   if (isset($additional_image_fields) && is_array($additional_image_fields) && !empty($additional_image_fields)) {   
    foreach ($additional_image_fields as $key => $val) {
      $register_array['image_votes'.$key_.$i] = (!empty($top_list[$i][$key])) ? format_text(trim($top_list[$i][$key]), 1) : REPLACE_EMPTY;
      $register_array['lang_'.$key] = $val[0];
    }   
}
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {   
    foreach ($additional_user_fields as $key => $val) {
      $register_array['image_votes'.$key_.$i] = (!empty($top_list[$i][$key])) ? format_text(trim($top_list[$i][$key]), 1) : REPLACE_EMPTY;
      $register_array['lang_'.$key] = $val[0];
    }   
}

Quote
else {
    $register_array['image_votes_'.$i] = "--";
    $register_array['image_votes_user_'.$i] = "--";
    $register_array['image_votes_cat_'.$i] = "--";
   $register_array['image_votes_showemail_'.$i] = "--";
   $register_array['image_votes_showhomepage_'.$i] = "--";
   $register_array['image_votes_hobbies_'.$i] = "--";
    $register_array['image_votes_number_'.$i] = "--";
    $register_array['image_votes_thumb_'.$i] = "--";
  }
}

modify top.html


Quote
<tr>
                            <td valign="top" class="row1" width="22%">{image_votes_thumb_1}</td>
                            <td valign="top" class="row1" width="76%">{lang_user_name}&nbsp;{image_votes_user_1}<br />
                            {lang_votes}&nbsp;{image_votes_number_1}<br />
                            {lang_category}&nbsp;{image_votes_cat_1}<br />
                            {lang_email}&nbsp;&nbsp;&nbsp;{image_votes_showemail_1}<br />
                            {lang_homepage}&nbsp;{if user_homepage}{image_votes_showhomepage_1}{endif user_homepage}<br />
                            {lang_user_hobbies}&nbsp;{image_votes_hobbies_1}</td>
                          </tr>

What is wrong
« Last Edit: February 14, 2008, 07:08:02 AM by masterred »
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Add new field top.php
« Reply #8 on: February 14, 2008, 12:47:00 PM »
Nowhere is step I say for add this:

Code: [Select]
$register_array['image_votes_hobbies_'.$i] = "--";

You add my step in keep first you do in first post ??  8O

hi

how cant add new fields in top.php

my change in top.php

modify top.php , new field {user_hobbies}

Code: [Select]
// Votes
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_rating, i.image_votes, c.cat_name".get_user_table_field(", u.", "user_name")." ".get_user_table_field(", u.", "user_email")."  ".get_user_table_field(", u.", "user_homepage")." ".get_user_table_field(", u.", "user_hobbies").", i.image_thumb_file

add this

Code: [Select]
$register_array['image_votes_hobbies_'.$i] .format_text($top_list[$i][$user_table_fields['user_hobbies']]);

add this

Code: [Select]
$register_array['image_votes_hobbies_'.$i] = "--";
template/my_template/top.html

add this

Code: [Select]
{lang_user_hobbies}&nbsp;{if user_hobbies}{image_votes_hobbies_1}{endif user_hobbies}
What is wrong or missing in AMENDED,
I taught in the profile data, but not in top.php

thank

If install my tweak, remove all step in first post first ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?