Versio

Zend View Helpers

Overzicht Reageren

Allard Jansen

Allard Jansen

25/08/2011 22:18:20
Quote Anchor link
Ik zit al een lange tijd vast. Ik heb net de volgende Helper gemaakt. Deze staat in de map "/application/views/helpers". Helaas lukt het mij niet deze Helper Class aan te roepen. Ik heb al een heel aantal dingen geprobeerd, maar niks werkt. Kan iemand helpen?

Mijn Helper (Notification.php)
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
/**
 * This is the get messages view helper class. You can use it, for setting some
 * error  messages for a  non-valid form. You also  can display some
 * modification messages, these will returned back to the user
 *
 * @author
 * @version
 */

 
class Zend_View_Helper_Notification extends Zend_View_Helper_Abstract
{    
    /**
     * Level the decorator class
     * @var string
     */

    private $_level = 'notice';
      
    /**
     * The message decorator
     * @var string
     */

    private $_decorator = '<p class="%s">%s</p>';
        
    /**
     * A pritty simple function, just set the level state
     * for the message. This can be different arguments
     */

    public function setLevel($level)
    {

        /**
         * Set the level of the message, this can be an error
         * but also a alert message
         */

        $this->_level = $level;
    }

    
    /**
     * Set the decorator in the class itself. This will
     * give the message a simple style
     */

    public function setDecorator($decorator)
    {

        /**
         * Just set the decorator for the message class        
         */

        $this->_decorator = $decorator;    
    }

  
    /**
     * The function itself - Display the Flash Messages that are
     * created in a form element
     */

    public function getMessages($messages = array())
    {
            
        /**
         * Split the array and put anything in an output
         * element. If is issn't an array, do nothing
         */

        foreach ($messages as $message)
        {

            if (is_array($message)) {
                list($this->_level, $message) = each($message);
            }

            
            /**
             * Create an output element for the message content
             */

            $output = sprintf($this->_decorator, $this->_level, $message);
        }


        /**
         * Return anything back to the view controller
         */

        return $output;
    }
    
}

?>


Dit staat in mijn Application.ini
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
recources.view.helperPath = APPLICATION_PATH . "/views/helpers"
Gewijzigd op 25/08/2011 22:19:24 door Allard Jansen
 
PHP hulp

PHP hulp

25/05/2012 20:01:11
Gesponsorde koppelingen:
 
Kees Schepers
Moderator

kees Schepers

31/08/2011 23:56:11
Quote Anchor link
Ik denk omdat de naam van je class "Zend_View_Helper_Notification" is en niet "Application_View_Helper_Notification"

En je moet het zo instellen in je application.ini:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
recources.view.helperPath.Application_View_Helper = APPLICATION_PATH . "/views/helpers"
 



Overzicht Reageren

Get Adobe Flash player