You are not logged in.

  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

1

Saturday, July 28th 2012, 4:32am

Fehler beim auslesen des Avatars

Hier der Error:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Fatal error: PHP notice in file /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/templates/compiled/29_0_1_teamlist.php (87): Trying to get property of non-object
Information:
error message: PHP notice in file /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/templates/compiled/29_0_1_teamlist.php (87): Trying to get property of non-object
error code: 0
file: /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/lib/system/WCF.class.php (281)
php version: 5.3.3-7+squeeze13
wcf version: 1.1.9 (Tempest)
date: Sat, 28 Jul 2012 02:31:37 +0000
request: /index.php?page=AboutUs&
referer: http://plugins.tvorwa.de/
Stacktrace:
#0 /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/templates/compiled/29_0_1_teamlist.php(87): WCF::handleError(8, 'Trying to get p...', '/var/www/virtua...', 87, Array)
#1 /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/lib/system/template/Template.class.php(267): include('/var/www/virtua...')
#2 /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/lib/page/AbstractPage.class.php(100): Template->display('teamlist')
#3 /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/lib/page/AbstractPage.class.php(46): AbstractPage->show()
#4 /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/lib/util/RequestHandler.class.php(64): AbstractPage->__construct()
#5 /var/www/virtual/plugins.tvorwa.de/htdocs/wcf/lib/util/RequestHandler.class.php(92): RequestHandler->__construct('AboutUs', Array, 'page')
#6 /var/www/virtual/plugins.tvorwa.de/htdocs/index.php(8): RequestHandler::handle(Array) 
#7 {main}



Hier die Zeile:

Source code

1
{if $user_id < 0}<img alt="" src="{@RELATIVE_WCF_DIR}images/{$avatar}" /></div>{else}{$user_id->user->GetAvatar()}{/if}

was ist da falsch?

vielen Dank im vorraus
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application




2

Saturday, July 28th 2012, 9:14am

Warum erstellst du dir denn die Variable für die userID nochmals neu? Und dann in einem Format, das so gar nicht zu Community Framework passt. :|
allgemein würde ich zudem sagen, dass es "getAvatar()" heißen muss, also mit kleinem "g" am Anfang.
Mit freundlichen Grüßen
Best regards
KittBlog Stile - Ihr Kit für Stile, Software und Knowhow
Your kit for styles, software and knowhow
Erste Linkliste zu Erweiterungen und Support rund um Burning Board©
First linklist for plugins and support around Burning Board©

  • "frmwrk_123" is male

Posts: 1,131

Location: Hamburg

Occupation: Informatikstudent

  • Send private message

3

Saturday, July 28th 2012, 12:12pm

Du musst beachten, dass die Zeilenangabe hier etwas verfälscht sein kann. Denn PHP gibt die Zeilennummer des kompilierten Templates an. Dort müsstest du hineinschauen, um zu wissen welche Zeile dort gemeint ist. Die Fehlermeldung besagt, dass auf eine Eigenschaft zugegriffen werden soll, obwohl es gar kein Objekt ist. Ist $user_id ein Objekt mit der Eigenschaft (Objektvariablen) user? Wenn nein, dann wird das auch nicht funktionieren.
Mit freundlichen Grüßen
frmwrk_123

Nützliche Plugins zum Selberbauen

  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

4

Saturday, July 28th 2012, 1:05pm

Ich wollte um setzen das wenn die user_id > 0 ist der Avatar des User geladen wird. Also auch von einem anderen User. Nur hab ich Probleme bei der Umsetzung
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application




nmichel

Member

Posts: 499

Occupation: Bitschieber

  • Send private message

5

Saturday, July 28th 2012, 1:13pm

$user_id kann nicht gleichzeitig Integer (if $user_id < 0) und Klasse ($user_id->user->GetAvatar()) sein
Der Kopf ist rund, damit das Denken die Richtung wechseln kann (Francis Picabia)

  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

6

Saturday, July 28th 2012, 1:18pm

Das weiß ich mittlerweile auch schon. Wie mache ich das denn, das es zur user-Klasse wird.
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application




nmichel

Member

Posts: 499

Occupation: Bitschieber

  • Send private message

7

Saturday, July 28th 2012, 1:24pm

Die Klasse, die du benötigst, gibt es bereits fertig im WCF: ./wcf/lib/data/user/UserProfile.class.php
Der Kopf ist rund, damit das Denken die Richtung wechseln kann (Francis Picabia)

  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

8

Saturday, July 28th 2012, 1:27pm

Mir geht es doch nicht jetzt um die Klasse sondern wie ich den Avatar auslese. Da hilft mir die Klasse relativ wenig wenn ich nicht weiß wie man auf diese Zugreift seitens des Templates oder des PHP Codes
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application




nmichel

Member

Posts: 499

Occupation: Bitschieber

  • Send private message

9

Saturday, July 28th 2012, 1:33pm

es wäre halt wichtig zu wissen, ob es nur der Avatar des aktuellen Users oder die Avatare verschiedener User sein sollen..
Der Kopf ist rund, damit das Denken die Richtung wechseln kann (Francis Picabia)

  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

10

Saturday, July 28th 2012, 1:37pm

Ich wollte um setzen das wenn die user_id > 0 ist der Avatar des User geladen wird. Also auch von einem anderen User. Nur hab ich Probleme bei der Umsetzung
also verschiedene user
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application




nmichel

Member

Posts: 499

Occupation: Bitschieber

  • Send private message

11

Saturday, July 28th 2012, 2:00pm

vielleicht so ?

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//wcf imports
...
require_once(WCF_DIR.'lib/data/user/UserProfile.class.php');

class .... {
    public $userProfiles null;
    public $defaultAvatar "....";

    ....

    public function getUsers() {
        $userProfiles = array();
        $sql "SELECT userID 
                    FROM   wcf1_user
                   WHERE ...";
        $result WCF::getDB()->sendQuery($sql);
        while($row WCF::getDB()->fetchArray($result)) {                                
            $userProfiles[] = new UserProfile($row['userID']); 
        }
    }
    ...
    
    public function assignVariables() {
        parent::assignVariables();
                
        WCF::getTPL()->assign(array(
            'userProfiles' => $userProfiles,
            'defaultAvatar' => $defaultAvatar                                 
        ));
    }
    ...
}


Template source code

1
2
3
{foreach from=userProfiles item=userProfile}
    <img src="{if $userProfile->userID > 0}$userProfile->getAvatar(){else}{@RELATIVE_WCF_DIR}images/{$defaultAvatar}{/if}" alt=""/>
{/foreach}
Der Kopf ist rund, damit das Denken die Richtung wechseln kann (Francis Picabia)

  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

12

Saturday, July 28th 2012, 4:26pm

Danke sehr du hast mir sehr geholfen. Habe es nun so gemacht:


PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
require_once(WCF_DIR.'lib/page/util/menu/HeaderMenu.class.php');
require_once(WCF_DIR.'lib/data/user/UserProfile.class.php');
    
HeaderMenu::setActiveMenuItem('wcf.header.menu.aboutus');

class AboutUsPage extends AbstractPage {
    public $templateName 'teamlist';
    public $AboutUsData;
    public $AboutUsStructure;
    public $Position;
    public $maxPositionData;
    public $userProfiles null;
    
    public function readParameters() {
        parent::readParameters();
        
        if (isset($_GET['category']))    $this->categoryID    intval($_GET['category']);
    }
    
    public function getUsers() {
        $userProfiles = array();
        $sql "SELECT userID FROM wcf1_user";
        $result WCF::getDB()->sendQuery($sql);
        while($row WCF::getDB()->fetchArray($result)) {                                
            $this->userProfiles[] = new UserProfile($row['userID']); 
        }
    }
    
    public function readData() {
        $sql "SELECT * FROM wcf".WCF_N."_aboutus_category";
        $result WCF::getDB()->sendQuery($sql);
        $row WCF::getDB()->fetchArray($result);
        
        $this->category $row['categoryName'];
        $this->categoryDescription $row['categoryDescription'];
    }
    
    public function assignVariables() {
        parent::assignVariables();
        
        
        $this->getMaxPosition();            
        $this->getData();
        $this->getUsers();
        WCF::getTPL()->assign(array(
            'groups' => $this->AboutUsStructure,
            'members' => $this->AboutUsData,
            'maxPositionData' => $this->maxPositionData,
            'maxPositionStructure' => $this->maxPositionStructure,
            'userProfiles' => $this->userProfiles,
        ));
    }
    
    protected function getMaxPosition() {
        $sql "SELECT c_id, showOrder FROM wcf".WCF_N."_aboutus_category  ORDER BY showOrder ASC";
        $result WCF::getDB()->sendQuery($sql);
        
        $this->maxPositionStructure WCF::getDB()->countRows($result);
        
        while ($row WCF::getDB()->fetchArray($result)) {
            $this->Position[] = $row;
        }
        
        if($this->Position){
            foreach ($this->Position as $key => $data){
                $sql "SELECT m_id FROM wcf".WCF_N."_aboutus_member WHERE c_id =".$data['c_id'];
                $result WCF::getDB()->sendQuery($sql);
                $this->maxPositionData[] = WCF::getDB()->countRows($result);
            }
        }
    }

    protected function makeStructure() {    
        $sql "SELECT * FROM wcf".WCF_N."_aboutus_category ORDER BY showOrder ASC";
        $result WCF::getDB()->sendQuery($sql);
        
        while ($row WCF::getDB()->fetchArray($result)) {
            $this->AboutUsStructure[] = $row;
        }
    }
    
    protected function getData() {
        $this->makeStructure();
        
        if ($this->AboutUsStructure){
            foreach ($this->AboutUsStructure as $key => $data){
        
                $sql "SELECT * FROM wcf".WCF_N."_aboutus_member WHERE c_id =".$data['c_id']." ORDER BY showOrder ASC";
                $result WCF::getDB()->sendQuery($sql);
            
                while ($row WCF::getDB()->fetchArray($result)) {
                    
                    $this->AboutUsData[] = $row;
                    
                    /*if($this->AboutUsData[]->u_id > 0){
                        $sql = "SELECT * FROM wcf".WCF_N."_user WHERE userID = ".$this->AboutUsData[]->u_id;
                        $result1 = WCF::getDB()->sendQuery($sql);
                        while ($row1 = WCF::getDB()->fetchArray($result1)) {
                            $this->AboutUsData[]->avatar = new Avatar($row["avatarID"]);
                        
                        }
                    }*/
                }
            }
        }
    }
}
?>


Template source code

1
2
3
4
5
6
{foreach from=$userProfiles item=userProfile}
                            	{if $userProfile->userID == $user_id}
                               		{@$userProfile->getAvatar()}                  
                                {/if}
                            {/foreach}
  {if $user_id == 0}<img src="{@RELATIVE_WCF_DIR}images/{$avatar}" alt=""/>{/if}
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application




Alexander Ebert

WoltLab Developer

  • "Alexander Ebert" is male

Posts: 4,773

Location: Berlin

  • Send private message

13

Saturday, July 28th 2012, 4:31pm

PHP Source code

7
HeaderMenu::setActiveMenuItem('wcf.header.menu.aboutus');

Das sollte niemals außerhalb der Klasse stehen, sondern innerhalb von show()!
Alexander Ebert
Developer WoltLab® GmbH


  • "I_LOVE_LINS" is male
  • "I_LOVE_LINS" started this thread

Posts: 121

Location: Cottbus

Occupation: Schüler

  • Send private message

14

Saturday, July 28th 2012, 4:36pm

ok werde ich in Zukunft machen
EasySCP - Die einfach bedienbare Server Administrationsanwendung
EasySCP - The new Server Administration Application