Code Monkey home page Code Monkey logo

frog_tags's Introduction

FrogTags Plugin Documentation

Brief

Frog tags are very similar to HTML tags. With FrogTags Plugin plugin enabled, you can use some standard Frog tags and first of all easily create own Frog tags.

FrogTags Plugin will add the same functionality to Frog CMS as offered by Radius tags in Radinat CMS (but with a preceding ‘f:’ instead of ‘r:’).

Configuration

To allow execution of PHP code as common in Frog CMS add the line

define(ALLOW_PHP, true);

to FROG_ROOT/config.php. (As this file is normally not writable you have to give yourself write permission to that file first!)

Defining Tags

The following example shows how Frog tags can be defined:

include_once(CORE_ROOT.'/plugins/frog_tags/index.php');
class MyTags extends FrogTags {
	public function tag_title() {
		return $this->page->title();
	}
}

As you can guess the tag defined above will output the current page’s title.

The FrogTags Plugin will automatically collect all methods whose names start with tag_ and whose classes are derived from class FrogTags.

The include line is required to assure that the class FrogTags is defined before it is used to derive an other class from it.

Using tags

The above defined tag could be used inside a page as in the following example:

Welcome to page <f:title />

The following is allowed aswell:

Welcome to page <f:title></f:title>

Using arguments

It is possible to pass arguments to a tag in the usual format argument="value". For example:

Welcome to page <f:title uppercase="yes" />

The passed arguments can be accessed inside a tag definition using the array $args. For example:

public function tag_title() {
	if ($this->args['uppercase'] == 'yes')
		return strtoupper($this->page->title());
	else
		return $this->page->title();
}

To mark an argument as required argument you can call the method require_argument() inside the tag definition. This method will return the required argument’s value aswell (or throw an exception if the argument has not been passed).

Tag content and nested tags

Like HTML tags Frog tags can have some content aswell. For example:

<f:uppercase>Welcome to page <title /></f:uppercase>

The content can be accessed inside a tag definition using the member variable $content. To parse the content and get the parsed result use the method expand(). For example:

public function tag_uppercase() {
	return strtoupper($this->expand());
}

It is also possible to pass some default arguments to the child tags. For example:

public function tag_uppercase() {
	$defaultArgs = array('uppercase' => 'yes');
	return $this->expand($defaultArgs);
}

To access the parent tag inside a tag definition use the member variable $parent. As $parent is a reference any changes made to $parent will affect the parent tag aswell.

As shortcut nested tags can be written for example as:

<f:children:each status="all">...</f:children:each>

This is equivalent to:

<f:children status="all"><f:each status="all">...</f:each></f:children>

frog_tags's People

Contributors

harendt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.