User Tools

Site Tools


Sidebar

tutorials:development:hello_world_tag

Hello World using Addon Tags

This tutorial will walk you through the steps for creating an addon that will replace an addon tag with the text Hello World. If you need to do any custom tag replacement (similar to how the built-in modules in the Geo software work), or insertion of text/HTML into a page, you can use this tutorial as a starting point.

Requires Geo 3.1 or higher.

  1. In the addons/ directory, create a new directory named "hello_world". <
  2. Inside the new directory, create a file named info.php. This file is what tells the Geo addon system what this particular addon can do. Use the following contents for this file:
<?php
//file /addons/hello_world/info.php
 
class addon_hello_world_info {
	var $name = 'hello_world';
	var $version = '1.0.0';
	var $title = 'Hello World';
	var $author = "Hello World, Inc.";
	var $description = 'Displays "Hello World" wherever you want to, using the correct tag.';
	var $auth_tag = 'my_addons';
	var $tags = array (
		'display_hello_world'
	);
}

<

  1. Now, create another new file named tags.php. This file is what defines what is replaced by the tags in the templates. This is the contents of tags.php:
<?php
//file: /addons/hello_world/tags.php
 
class addon_hello_world_tags {
	function display_hello_world($params, $smarty){
		//Note: The method name matches the tag name used in the $tags var in info.php
		return "Hello World!";
	}
}

<

  1. Now, go into addon management at Addons > Manage Addons, and you should see the addon named Hello World. Install and enable that addon. <
  2. While still in addon management, hover over the addon and click so that it makes the addon's info "stick". On the info for the addon, there should be the tag to use. The tag should be something like this:

{addon author='my_addons' addon='hello_world' tag='display_hello_world'} but don't take our word for it, verify that that is the tag name by looking at the details of the addon. <

  1. Copy and paste that tag into a template wherever you want it to display.<
  2. If everything is done correctly, you should now see the hello world text displayed wherever you placed the tag in the templates. <

This isn't the limit of what addons can do, to see everything addons can do get the example addon (should be a free addon in the client area). It demonstrates the use of tags, along with all of the other current abilities of addons. Plus, as long as you make your addon name unique enough (the addon's folder name), you shouldn't have to worry about having name conflicts with future addons.

tutorials/development/hello_world_tag.txt · Last modified: 2014/09/25 16:55 (external edit)