Author Topic: Next- // Previous-Buttons on User-Profil - Vor- und Zurückbottons im User-Profil  (Read 24167 times)

0 Members and 1 Guest are viewing this topic.

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Hi

Is there a possibility to have next- and previous-buttons on the user-profile? So it would be easy to go from one user-profile to the next or back.
I've already implemented the memeberlist. The new features would be a great value add

Thanks for feedback



Hallo

Gibt es eine Möglichkeit, Next- und Zurück-Buttons auf der Profil-Seite zu implementieren? So könnte man von einem Profil zum anderen klicken.
Die Memberliste habe ich implementiert. Die neue Funktionalität wäre eine zusätzliche Möglichkeit, Users kennenzulernen.

Danke für Feedback.

TIMT

Offline dosensteck

  • Full Member
  • ***
  • Posts: 160
    • View Profile
$next_id = $user_id + 1;
$last_id = $user_id - 1;

in der member.php unter showprofile angeben, variable registrieren und als link ausgeben

<a href="/member.php?action=showprofile&user_id={next_id}>Nächstes Profil</a>
<a href="/member.php?action=showprofile&user_id={last_id}>Voriges Profil</a>

Ist jetzt nur als Tipp gemeint, ich habe selbst keine Möglichkeit das zu testen da bei mir die Phpbb Profile benutzt werden.
Sei nur angemerkt das es eine ziemlich schlechte Möglichkeit wäre. Hast du zb. einen User gelöscht und die ID 50 fehlt hat man keine Chance wenn man von ID 49 weiterspringt weiter auf ID 51 zu kommen usw.

Naja, wie gesagt nur eine möglichkeit die nicht besonders astrein ist ;)

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
wie du selbst schon gesagt hast,
ist die von meinem Vorposter angegebe Möglichkeit nur sehr begrenzt.

Nutz lieber 2 SQL Abfragen, wo dann jeweils als where argument steht user_id > $user_id
(wobei $user_id, die Userid des gerade aufgerufenen Profils ist)
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Hallo IcEcReaM

Das klingt doch sehr vielversprechend  :)

Allerdings bin ich weder in SQL noch in PHP sehr bewandert.

Könntest du mir den Code entsprechend posten?

Vielen Dank!!

Gruss
TIMT

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
mal schauen, wenn ich zeit finde.
ist nur ne kleine code änderung.
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
in member.php folgendes suchen:

Code: [Select]
if ($action == "showprofile") {
  $txt_clickstream = $lang['profile'];
  if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
    $user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
    if (!$user_id) {
      $user_id = GUEST;
    }
  }
  else {
    $user_id = GUEST;
  }
 
  if ($user_row = get_user_info($user_id)) {

danach einfügen:
Code: [Select]
  // show next and previous profile link
  $sql ="SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("","user_id")." > $user_id
         ORDER BY ".get_user_table_field("","user_id")." ASC
         LIMIT 0,1";
  $result_profile_next = $site_db->query_firstrow($sql);
  $sql ="SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("","user_id")." < $user_id
         ORDER BY ".get_user_table_field("","user_id")." DESC
         LIMIT 0,1";
  $result_profile_previous = $site_db->query_firstrow($sql);
  $profile_next_userid = (isset($result_profile_next[$user_table_fields['user_id']]) && $result_profile_next[$user_table_fields['user_id']]> GUEST) ? $result_profile_next[$user_table_fields['user_id']] : 0;
  $profile_previous_userid = (isset($result_profile_previous[$user_table_fields['user_id']]) && $result_profile_previous[$user_table_fields['user_id']]> GUEST) ? $result_profile_previous[$user_table_fields['user_id']] : 0;

  $site_template->register_vars(array(
      "profile_next_link" => ($profile_next_userid) ? "<a href=\"".$site_sess->url(ROOT_PATH."profile.php?action=showprofile&amp;".URL_USER_ID."=".$profile_next_userid)."\">Next Profile</a>" : "",
      "profile_previous_link" => ($profile_previous_userid) ? "<a href=\"".$site_sess->url(ROOT_PATH."profile.php?action=showprofile&amp;".URL_USER_ID."=".$profile_previous_userid)."\">Previous Profile</a>" : "",
  ));
  // show next and previous profile link


du kannst dann in der member_profile.html folgende tags benutzen:
{profile_previous_link}
{profile_next_link}

Code ist nur auf die schnelle dahingecodet, nur das nötigste wurde bedacht.
« Last Edit: March 07, 2006, 11:24:06 PM by IcEcReaM »
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
coole Sache :) Funktioniert!!!!
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Wie gesagt, der Code ist allerdings nur auf die schnelle dahin gecodet,
man könnte noch die SQL Abfrage optimieren,
und beispielsweise auch den Usernamen des nächsten profils anzeigen lassen.
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
works great!

 but ...
it works only (for me) when i change profile.php with member.php and make the changes in the member.php

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
i changed my post above.
there is nor profile.php,
this was an mistake cause i was chanfig the member_profile.html...^^

Of course you have to change the member.php
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Hi IcEcReaM

Thanks, it works great.

I have at least two usergroups:
customer
photographer

Now I'd like to show only the profiles from the users belonging to the usergroup photographer.

How can I do that?

Thanks!

TIMT

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
With the next- / back-button, I'd like to show only profiles from users who belong to usergroup ID=1.

How can I do that?

Thanks for helping me!

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Ersetze das bei meinem oben genannten Post:
Code: [Select]
SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("","user_id")."
durch das:
Code: [Select]
SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("","user_level")." = $user_info['user_level'] AND  ".get_user_table_field("","user_id")."
kommt zweimal vor.

(nicht gestestet)
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
I get the following error:

Code: [Select]
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Inetpub\wwwroot\photofrontal\member.php on line 1117
Where do I have define the number of the usergroup? I want only show the users with usergroup = 1 (photograpers).


Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Code: [Select]
  // show next and previous profile link
  $sql ="SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("","user_level")." = $user_info['user_level'] AND  ".get_user_table_field("","user_id")." > $user_id
         ORDER BY ".get_user_table_field("","user_id")." ASC
         LIMIT 0,1";
  $result_profile_next = $site_db->query_firstrow($sql);
  $sql ="SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("","user_level")." = $user_info['user_level'] AND  ".get_user_table_field("","user_id")." < $user_id
         ORDER BY ".get_user_table_field("","user_id")." DESC
         LIMIT 0,1";
  $result_profile_previous = $site_db->query_firstrow($sql);
  $profile_next_userid = (isset($result_profile_next[$user_table_fields['user_id']]) && $result_profile_next[$user_table_fields['user_id']]> GUEST) ? $result_profile_next[$user_table_fields['user_id']] : 0;
  $profile_previous_userid = (isset($result_profile_previous[$user_table_fields['user_id']]) && $result_profile_previous[$user_table_fields['user_id']]> GUEST) ? $result_profile_previous[$user_table_fields['user_id']] : 0;

  $site_template->register_vars(array(
      "profile_next_link" => ($profile_next_userid) ? "<a href=\"".$site_sess->url(ROOT_PATH."profile.php?action=showprofile&amp;".URL_USER_ID."=".$profile_next_userid)."\">Next Profile</a>" : "",
      "profile_previous_link" => ($profile_previous_userid) ? "<a href=\"".$site_sess->url(ROOT_PATH."profile.php?action=showprofile&amp;".URL_USER_ID."=".$profile_previous_userid)."\">Previous Profile</a>" : "",
  ));
  // show next and previous profile link

So sollte das aussehen,
wahrscheinlich hast du oben zuviel ersetzt.

Ich dachte du willst die Usergruppen anzeigen abhängig von der Usergruppe desjenigen der gerade die Profile durchschaut?
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump