Hallo, Gast! (Registrieren)

Letzte Ankündigung: MyBB 1.8.38 veröffentlicht (30.04.24)


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste
Statusfunktion/Kommentarfunktion z.b. im Profil
#4
So - da ich noch immer nichts passendes gefunden hab - hab ich mich selber dran gesetzt und angefangen den userpage mod umzuschreiben bzw. für meine wünsche anzupassen.
bisher ziemlich dirty - also noch keinerlei sicherungen etc - aber wenigstens funktioniert es zum Teil.
Betonung auf zum Teil - ich hab einigie Probleme selber gelöst - aber jetzt komm ich partout nicht weiter.
Ich habe?
2 weitere tabellen angelegt - eine mybb_follow für kommentare. 
(mybb_follow - Felder: id (ai), mpid (um zu speichern auf welcher userpage man ist), st_author, st_avatar, status, date)
Hier funktioniert alles soweit - auf der entsprechenden Userpage, werden die entsprechenden Kommentare angezeig - samt Avatar, Inhalt und ausgewählten Datum
plus ein weiteres Textfeld - in das jetzt die antwort für das entsprechende Kommentar getippt werden kann.
Also -> zweite Tabelle. Hier hab ich jetzt noch etwas improvisiert ein Feld erstellt, in dass die nummer von dem Kommentar auf das geantwortet werden kann gespeichert wird.
(Name: mybb_fafollow - Felder: fa_id (ai), hidden_field (um zu speichern auf welches kommentar man antwortet), fa_st_author, fa_st_avatar, fa_status, fa_date)
Also speichern klappt soweit - er trägt alles was er soll in die Datenbank in die enstsprechenden Felder ein.

Mein Problem ist jetzt die Ausgabe, an der ich nicht weiter komme. Er soll ja die antworten nur bei den entsprechenden Kommentaren einfügen. Also muss ich hier ja eigentlich über mein hidden_field arbeiten und den dort gespeicherten wert mit der (mybb_follow) id vergleichen und nur die entsprechenden ausgeben.
Das ist das eine Problem.
Mittlerweile gibt er mir die Antworten unter den Kommentaren aus, allerdings immer alle. Ich hänge also definitiv am select. Kann mir hier jemand helfen, bitte?
PHP-Code:
    $fa_follower=$db->query("SELECT * FROM 
mybb_fafollow LEFT JOIN mybb_follow ON mybb_fafollow.hidden_field = id 
WHERE mybb_fafollow.hidden_field = mybb_follow.id"
); 



Wie schon erwähnt - ich bin eher ein php neuling und hab mich... ziemlich durchgeraten und viel einfach ausprobiert. Bisher hab ich das ganze auch nur lokal auf meinem rechner getestet. (Da kann wenigstens nicht viel kaputt gehen ^^)

Also - jetzt zu meinem Code und meinen templates:
Ich häng einmal den kompletten code als attachment an und poste hier nur den part den ich selber hinzugefügt hab.

templates dann auch im anhang ^^


PHP-Code:
​    // start usercomments
    /** * Prüfen ob Variablen einen wert gespeichert haben -> dann speichern.*/
     
if ($_POST['senden'] != '' AND $_POST['status'] != '') {        
    
//build data for insert
        //date 
        
$month=$_POST['month'];
        
$dt=$_POST['dt'];
        
$year=$_POST['year'];
        
$datum sprintf("%d-%d-%d"$_POST['year'], $_POST['month'], $_POST['dt']);
        
 
       //array with input for fields
        
$follow = array(
        
"date" => $datum,
        
"st_author" => build_profile_link($mybb->user['username'], $mybb->user['uid']),
        
"mpid" => $memprofile['uid'], //save on which Page the comment is posted
        
"id" => $mybb->input['id'],
        
"status" => $mybb->input['status'],
        
"st_avatar" => $mybb->user['avatar'],
    );    
    
//add new comment
        
$db->insert_query("follow"$follow);
 
       }
 
   
    
// set var to select the right comments for the right userpage
 
   $mpid $memprofile['uid']; 
 
   //create comments on userpage
    // save data for answer    
    
if ($_POST['fa_senden'] != '') {
            
//date for answer
            
$fa_month=$_POST['fa_month'];
            
$fa_dt=$_POST['fa_dt'];
            
$fa_year=$_POST['fa_year'];
            
$fa_datum sprintf("%d-%d-%d"$_POST['fa_year'], $_POST['fa_month'], $_POST['fa_dt']);
            
            
// build array of commentanswer data
            
$fa_follow = array(
            
"fa_id" => $mybb->input['fa_id'],
            
"fa_date" => $fa_datum,
            
"fa_st_author" => build_profile_link($mybb->user['username'], $mybb->user['uid']),
            
// not used "fa_commentid" => $commentid,
            
"fa_status" => $mybb->input['fa_status'],
            
"hidden_field" =>$mybb->input['hidden'],
            
"fa_st_avatar" => $mybb->user['avatar'],
            );    
            
//add new answer to comment
            
$db->insert_query("fafollow"$fa_follow);
        }    
    
    
$follower=$db->query("SELECT * FROM mybb_follow WHERE mybb_follow.mpid = '$mpid' ORDER BY mybb_follow.date DESC");

    
// create answers:
    //try to select the right ones. Should only show the anwers to the comment there where postet to. (hidden_field = id of commentar)
    // at the moment: it takes just this answers, where it found a comment with same id, but give them to all comment - not just to those - where the answer should stand
    //the first commentar gets no answers... why? 
    
$fa_follower=$db->query("SELECT * FROM mybb_fafollow LEFT JOIN mybb_follow ON mybb_fafollow.hidden_field = id WHERE mybb_fafollow.hidden_field = mybb_follow.id");
    
    
// output for the comments - working so far.
        
while($result=$db->fetch_array($follower)) {
        
$avatar $result['st_avatar'];
        
$username $result['st_author'];
        
$status_feld $result['status'];
        
$datum_feld $result['date'];    
                
        
//save the id in the value of the hidden field - so every comment has his own 'anwser id' save in the hidden field.
        // save this one in mybb_fafollow - workaround
        // didn't know how to save it directly - so save it in the value -> in the input the id is saved.
        
$commentid $result['id'];
         
        
// if i put the fakommentar eval here - he shows some answers - but complete weird ^^ counting up or some sort
        // eval("\$follow_fakommentar .=\"".$templates->get("follow_fakommentar")."\";"); 
    

 
       // try to select just the comments, where somethin is saved 
        
if (isset($fa_follower)) {
            while(
$fa_result=$db->fetch_array($fa_follower)) {
                
$fa_avatar $fa_result['fa_st_avatar'];
                
$fa_username $fa_result['fa_st_author'];
                
$fa_status_feld $fa_result['fa_status'];
                
$fa_datum_feld $fa_result['fa_date'];
             
                
//seems to work here, but do not select the right ones.
                 
eval("\$follow_fakommentar .=\"".$templates->get("follow_fakommentar")."\";"); 
                }    
            
            
//eval("\$follow_kommentare .= \"".$templates->get("follow_kommentare")."\";"); 
            
}
        
//    eval("\$follow_fakommentar .=\"".$templates->get("follow_fakommentar")."\";");
    
        // this has to be here, cause otherwise the first comment gets no answers
        
eval("\$follow_kommentare .= \"".$templates->get("follow_kommentare")."\";"); 

    }

    
//end answer comment
     // if i put it here as expected: does nothing. 
    //eval("\$follow_fakommentar .=\"".$templates->get("follow_fakommentar")."\";"); 
    
    
    //create the template where the formular for the status is and which calls the follow_kommentar
    
eval("\$followpage = \"".$templates->get("followpage")."\";");  
    
//end own comments
    
    
eval("\$page = \"".$templates->get('userpages_content')."\";");
        
output_page($page); 
        die();
    }
}    

/*
*    End User Profile
*/

?>


Angehängte Dateien
.txt   follow_fakommentar.txt (Größe: 2,25 KB / Downloads: 8)
.txt   follow_kommentar.txt (Größe: 2,25 KB / Downloads: 5)
.txt   followpage.txt (Größe: 2,03 KB / Downloads: 5)
.txt   userpages_content.txt (Größe: 552 Bytes / Downloads: 4)
.php   userpages.php (Größe: 26,32 KB / Downloads: 2)
Zitieren


Nachrichten in diesem Thema
RE: Statusfunktion/Kommentarfunktion z.b. im Profil - von Risu - 16.08.2014, 18:31

Möglicherweise verwandte Themen…
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Kommentarfunktion SHINDY 0 963 11.03.2016, 17:44
Letzter Beitrag: SHINDY