Online Games Grumpy Unix Fart Contact Us

Config::General::Extended

GenieMod uses Config::General::Extended (available at CPAN) for it's configuration requirements.

This was selected because of it's flexibility, you can easily define your own sections (for example database sections, smtp server sections, etc..) and then use those sections in your design.

Lets look at the configuration for the viewmap.


Sample view map configuration section

    # Default view map. 
    <viewmap default>
        # Template configuration.
        <template>
            path "t/view/tmpl/local:t/view/tmpl/stock"
        </template>
        <view error>
            <args>
                file "error.ptml"
            </args>
        </view>
        <action default_index>
            <view ok>
                <args>
                    file "index.ptml"
                    txt.message "test_arg"
                </args>
            </view>
            <view error>
                package = "GenieMod::View::Template"
                # perlfile = "GenieMod/View/Template.pm"
                <args>
                    file = "error.ptml"
                </args>
            </view>
        </action>
        <action do_foo>
            <view ok>
                <args>
                    file = "ok.ptml"
                </args>
            </view>
        </action>
    </viewmap>

Woah! looks complicated? Not really, it's an entry in a Config::General object, anyone who has used apache should recognize the syntax.

Local area

Local views apply to a specific action, in this case, a method of the controller class called do_foo()

    <action do_foo>
        <view ok>
            <args>
                file = "ok.ptml"
            </args>
        </view>
    </action>


The args are fed into the create() method as a hash, (so you can set up parameters such as messages to display or files to use in a template system)

Whenever a request for a view named error is requested, it first checks the named action section, if found it will return that view. In our do_foo section, there is no such error view, so, we fall back to the global area.

Global area

ViewMap recognizes global and local mappings. The global section in the above example has a view named error

    <view error>
        <args>
            file "error.ptml"
        </args>
    </view>

In this manner, it is possible to use a generic error page for each controller "action method" that requests one. If you wanted a custom error page for a specific action, (such as the default_index action, listed above) you could simply assign one.

Send to a friend

[add]
Please enter code (Change Code)

Sending Message.