Open main menu
MediaWiki extensions manual
OOjs UI icon advanced.svg
Views
Release status: beta
Extension-Views.png
Implementation MyWiki
Description Allows to avoid inline HTML
Author(s) (Vedmakatalk)
Latest version 0.1 (2013-08-24)
MediaWiki 1.18+
Database changes No
License GPL v3
Download
README
Translate the Views extension if it is available at translatewiki.net
Check usage and version matrix.

The Views extension brings some templating in dev process to separate HTML and PHP which allows to avoid inline HTML.

Instead of using inline HTML blocks in PHP, just use Views.

InstallationEdit

  • Download and place the file(s) in a directory called Views in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/Views/Views.php";
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

UsageEdit

  1. While developing an extension create directory called "views" in your extension folder.
  2. Place some standard php-templates in this directory, for example: template.php with contents
<div>
 <p> <? echo $a ?> </p>
 </div>

Somewhere in your code call Views:

$data = array( $a => 'hello' );
$html = Views::forge('template', $data);

This will parse template, extract variables and return result into $html variable.

Result will be:

 <div>
 <p> hello </p>
 </div>

Thats it!