-
Notifications
You must be signed in to change notification settings - Fork 1
Examples
Gargaj edited this page Oct 5, 2024
·
4 revisions
<?php
include_once("contentifier/contentifier.php");
class MyContentifier extends Contentifier
{
public function sqlpass() { return "contentifier123"; }
}
$contentifier = new MyContentifier();
$contentifier->run();
?>
<?php
include_once("contentifier/contentifier.php");
class MyContentifier extends Contentifier
{
public function sqldsn() { return "sqlite:test.db"; }
public function sqlpass() { return null; }
}
$contentifier = new MyContentifier();
$contentifier->run();
?>
<?php
include_once("contentifier.min.php");
class MyContentifier extends Contentifier
{
public function sqldsn() { return "mysql:dbname=myotherdatabase"; }
public function sqluser() { return "myusername"; }
public function sqlpass() { return "mypass"; }
}
$contentifier = new MyContentifier();
$contentifier->run();
?>
<?php
include_once("contentifier/contentifier.php");
class MyContentifier extends Contentifier
{
public function sqlpass() { return "contentifier123"; }
public function render() { include_once("template.inc.php"); }
}
$contentifier = new MyContentifier();
$contentifier->run();
?>
In template.inc.php
:
<?php
$content = $this->content();
if ($content === false || $content === null)
{
header("HTTP/1.1 404 Not Found");
$content = "<h1>404</h1><p>Page '".$this->escape($this->slug)."' not found</p>";
}
?>
<!DOCTYPE html>
<html>
<head><link href="<?=$this->rooturl()?>design/style.css" rel="stylesheet" media="all"></head>
<body>
<nav><?=$this->menu()?></nav>
<div id="content"><?=$content?></div>
</body>
</html>
<?php
include_once("contentifier/contentifier.php");
class MyPagePlugin extends ContentifierPagePlugin
{
public function id() { return "year"; }
public function adminmenuitem() { return null; }
// This plugin will handle pages at e.g. http://mysite/year/1994
public function slugregex() { return "year\/([0-9]{4})"; }
// The matches above are passed down as parameter here
public function content($match) { return "The year is ".$match[1]."."; }
}
class MySCPlugin extends ContentifierShortCodePlugin
{
private $contentifier;
public function __construct($contentifier) { $this->contentifier = $contentifier; }
public function id() { return "sc"; }
public function adminmenuitem() { return "SC"; }
public function shortcode() { return "shortcode"; }
public function content($p)
{
$out = "[start shortcode]\n";
if (count($p)>=2) $out .= sprintf("%d * %d = %d\n",$p[0],$p[1],$p[0]*$p[1]);
$out .= "user count: " . $this->contentifier->sql->SelectRow("select count(*) as c from users")->c."\n";
$out .= "[end shortcode]\n";
return $out;
}
}
class MyContentifier extends Contentifier
{
public function sqlpass() { return "contentifier123"; }
}
$contentifier = new MyContentifier();
$contentifier->addplugin( new MyPagePlugin() );
$contentifier->addplugin( new MySCPlugin($contentifier) );
$contentifier->run();
?>