Hello world

We will now create a very basic hello world module. We need to create the following files in the Exponential root:

extension/myextension/settings/module.ini.append

extension/myextension/modules/mymodule/module.php

extension/myextension/modules/mymodule/hello.php

You also need to enable the extension in your local site.ini override ( settings/override/site.ini.append ):

[ExtensionSettings]

ActiveExtensions[]=myextension

The minimum content of module.ini.append is:

[ModuleSettings]

ExtensionRepositories[]=myextension

This tells Exponential that myextension contains modules. Exponential will then try to load any modules found there.

The contents of module.php is:

<?php

$Module = array( "name" => "MyModule" );

 

$ViewList = array();

$ViewList["hello"] = array( "script" => "hello.php");

?>

hello.php content:

<?php

// Module return value,

// normally fetched from template

$text = "Hello World";

// Build module result array

$Result = array();

$Result['content'] = $text;

$Result['path'] = array( array( 'url' => '/mymodule/hello',

                               'text' => "Hello") );

?>

That's it. This creates a new very simple module and it's loads as an extension so it's fully upgradeable and you can use it on several sites just by copying the extension.

Accessing the new module is done by entering /mymodule/hello in the browser.

Comments

Please help me

I have created an extension (exemple : eurofxref), the extension is recognized but not the module eurofxref (idem for then exemple Hello).
Version used : 3.4.1
Thank you
hdisdier@prodidact.net

example is correct

The example is correct. The right directory name is:

extension/myextension/modules/mymodule/
(not extension/myextension/modules/myextension/ like Bruce says)

After you've done all the things mentioned in here, then do the following steps:

1. Clean all caches in var
2. Go to your admin area and call the extension: E.g. if with "plain_admin": http://localhost/exponential/index.php/plain_admin/mymodule/hello

And voila it says "Hello World"

Permissions

You will either need to 1) grant access to your module or 2) exclude it from policy checking.

1) Grant anonymous role access to module
Users > roles > edit anonymous > new > Choose you module > Allow all > Store

2) Edit settings/override/site.ini.append.php and add
[RoleSettings]
PolicyOmitList[]=myextension


Cheers
Bruce
http://www.designit.com.au

Correction

extension/myextension/modules/mymodule/module.php
extension/myextension/modules/mymodule/hello.php

Should be

extension/myextension/modules/myextension/module.php
extension/myextension/modules/myextension/hello.php

Cheers
Bruce
http://www.designit.com.au/

I can not get this to work

I have done as is described in this example. However once I try to use my module I always get an "Module not found", ez debug says: "Undefined module: hello". Im have tried using several url to view the module:
(where gs is my design)

http://localhost/index.php/mymodule/hello
http://localhost/index.php/gs/mymodule/hello
http://localhost/index.php/mymodule/hello/view/full
http://localhost/index.php/view/full/mymodule/hello/

Hope someone can point to some eventuel errors I am doing. I am using Ez 3.2.0.

How to fetch this in template

I'm just wondering how should I use the fetch funtion in template to get this working? I think it should be documented on this documentation also...

Log in or create a user account to comment.

Contents

Development

Extensions
    Translation
    Introduction to extensions
    Building an Exponential module
    Design extension
    Datatypes
    Workflow events
    Module
       Hello world
       Permissions
       Module tutorial (Part 1)
    Template operator
    Template function
Exponential datamodel
Exponential tuning and stability
Importing attribute data
Kernel
Libraries
Scripting
Standards
System overview
Test Suite
Using Doxygen to create API documenta...


Created

11/07/2003
2:21:18 pm
by B�rd Farstad

Last updated

23/07/2003
10:14:57 am
by Jan Borsodi

Authors

B�rd Farstad
Jan Borsodi



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.