GithubHelp home page GithubHelp logo

dajare / wolf_tags Goto Github PK

View Code? Open in Web Editor NEW

This project forked from harendt/frog_tags

3.0 3.0 2.0 141 KB

XML-like tags for Wolf CMS, modelled on Radiant CMS's Radius tags.

Home Page: http://adajer.byethost5.com/wolftags

License: GNU General Public License v3.0

PHP 100.00%

wolf_tags's Introduction

WolfTags Plugin Documentation

Brief

Wolf tags are similar to XHTML or XML tags. With the WolfTags Plugin enabled, you can use a set of standard WolfTags and even create more of your own.

WolfTags Plugin will add a similar functionality to Wolf CMS as that offered by Radius tags in Radiant CMS (but with a preceding ‘w:’ instead of ‘r:’).

WolfTags may be used in a Page, Snippet, or Layout. See the Sample Layout (included) for further examples of usage.

Configuration

Optional: To allow execution of PHP code as common in Wolf CMS add the line:

define(ALLOW_PHP, true);

to WOLF_ROOT/config.php. (As this file is normally not writable you have to give yourself write permission to that file first!) Otherwise, only WolfTags will be available for dynamic functions in the backend.

Defining Tags

The following example shows how Wolf tags can be defined:

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

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

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

The include line is required to ensure that the class WolfTags is defined before it is used to derive another class from it.

Using tags

WolfTags can be included on pages which use either the Textile or Markdown text filter. (And usage with Textile does not require any “notextile.” markup.)

The WolfTag defined above could be used inside a page like this:

Welcome to page <w:title />

The following is also allowed:

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

Using arguments

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

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

The arguments passed 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 you can call the method require_argument() inside the tag definition. This method will return the required argument’s value as well (or throw an exception if the argument has not been passed).

Tag content and nested tags

Like HTML tags, Wolf tags can wrap around content as well. For example:

<w:uppercase>Welcome to page <w:title /></w: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 as well.

As a shortcut, nested tags can be written for example as:

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

This is equivalent to:

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

wolf_tags's People

Contributors

dajare avatar harendt avatar

Stargazers

Mike Bingaman avatar André Philip avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

bingaman vintzl

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.