2009-11-28, 01:28 PM
I was editing the Hellow world plugin as a template, and basically instead of writing hello world, I want it to write a variable, $i so I defined $i=1;
And then I edited the line in the post template so it wrote $i, but instead of echoing the number "1", it just echoes nothing.
Here is the edited file, with the two lines which are significant highlighted in red.
And then I edited the line in the post template so it wrote $i, but instead of echoing the number "1", it just echoes nothing.
Quote:<?php
/**
* MyBB 1.4
* Copyright © 2008 MyBB Group, All Rights Reserved
*
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*
* $Id: hello.php 4304 2009-01-02 01:11:56Z chris $
*/
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("pre_output_page", "hello_world");
$plugins->add_hook("postbit", "hello_world_postbit");
function hello_info()
{
/**
* Array of information about the plugin.
* name: The name of the plugin
* description: Description of what the plugin does
* website: The website the plugin is maintained at (Optional)
* author: The name of the author of the plugin
* authorsite: The URL to the website of the author (Optional)
* version: The version number of the plugin
* guid: Unique ID issued by the MyBB Mods site for version checking
* compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported.
*/
return array(
"name" => "Hello World!",
"description" => "A sample plugin that prints hello world and prepends the content of each post to 'Hello world!'",
"website" => "http://www.mybboard.net",
"author" => "MyBB Group",
"authorsite" => "http://www.mybboard.net",
"version" => "1.0",
"guid" => "",
"compatibility" => "*"
);
}
//loooooooooooooooooooool
$i=1;
function hello_world($page)
{
$page = str_replace("<div id=\"content\">", "hi", $page);
return $page;
}
function hello_world_postbit($post)
{
$post['message'] = "<strong>$i</strong><br /><br />{$post['message']}";
}
?>
Here is the edited file, with the two lines which are significant highlighted in red.