Overview

codeigniter-xhtml-library by Serafim Junior Dos Santos Fagundes Cyb3r Network

Version 1.2.1

MIT License

Copyright (c) 2010 Serafim Junior Dos Santos Fagundes Cyb3r Network

--------------------------------------------------------------------------------

codeigniter-xhtml-library is a CodeIgniter library for Strict XHTML 1.0 document
generation. The goal of the library is to remove the burden (although it ain't
really one) of switching between HTML and PHP and to give a 100% PHP focus to
the coder. This library serves also as an experiment of maintenance for tag
generation with PHP.

--------------------------------------------------------------------------------
Usage
=====

In the controller...
--------------------

Load the library.

	$this->load->library( 'xhtml' );

You can pass an array as the second parameter for the language, encoding and
XHTML version to the resulting document:
	
Value of key 'version' is one of these:

- 'xhtml11'
- 'xhtml1-strict'
- 'xhtml1-trans'
- 'html4-trans'

	# Displaying default values
	$params = array( 'encoding' => 'utf-8', 'short_lang' => 'en', 'version' => 'xhtml1-strict' );

	$this->load->library( 'xhtml', $params );

In the view...
--------------

Create the XHTML tags in the views.

	# Create <head>
	$head = $this->xhtml->head();

		# Create tag <title>
		$title = $this->xhtml->title( 'My first document' );

	# Append <title>
	$head->append( $title );

		$charset = $this->config->item( 'charset' );

		$attrs = array();

		$attrs['Content-Type'] = "text/html;charset=".$charset;

		# Create tag <meta> with attributes
		$meta = $this->xhtml->meta( $attrs );

	$head->append($meta);

		# Create tag <h1>
		$h1 = $this->xhtml->h1( 'Hello World!' );

		# Set id
		$h1->id( 'myHeader' );

		# Attributes for <h1> tag
		$h1->attr( 'style', 'color:red;' );
	
	# Append <h1>
	$body->append( $h1 );
	
		# Create tag <p> with attributes
		$p = $this->xhtml->p( 'Lorem ipsum...', $attrs );
		
		# Set class
		$p->klass( 'lorem' );

	$body->append( $p );

	# Add $head and $body to doc
	$doc = $this->xhtml->doc( $head, $body );

	# Generate and echo XHTML document
	$doc->output();


Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.