OneThird CMS

Lightweight CMS for Small website, Web application framework.

Download Document

japanese

To create a ToDo app (4): make a Todo list

In the tutorial up to the last time, you can now add Todo

In addition, thanks to the folder plug-ins, you can also see a list of Todo

However, essential of Todo is not listed or open whether close of the


So, we would like to change it to display the list of to have Open / Close of the data entered in the metadata


For the sake of simplicity to this, we want to do the remodeling is based on a simple_folder.php template module that lists the data of the lower folder


download than it will download the simple_folder.php


structure commentary of simple_folder.php

contents of sumple_folder.php has become less of such a structure


File top part

<? Php

/* simple_folder : page folder

name : simple_folder

author: team1/3

*/

global $params,$config;

if (!isset($config)) { die(); }

draw();

$params['rendering'] = false;


The file first part, I There are comments

Comment is intended to be able to select the Page Properties

part of isset is a guard when it is called a php file directly (charm)

$params ['rendering'] = false; part of is to make it OFF the default plotting system

Default drawing system and is usually of the page, edit the text / display, is a system that displays the inner page (block system)

If you say it and why to OFF, because earlier in the folder view of the power is not turned OFF body (description of the page) would have been done

In the page folder, page text - you have to be displayed in the folder view of the order - inner page

To OFF in order to this order

at the portion of the draw, we will do the drawing of page


A description of each function

draw ... drawing blog Lamb

event hooks that occurs just before modifying the my_page_folder_onbefore_modified ... page text

write_page_folder ... plug-in settings (settings of the parent page / editing rights, the provision of page / folder additional functions)

my_page_folder ... query to the database (collection of the lower page)

my_page_folder_writer ... 表示部分


In draw function, the operation of this template module but will start, in fact, you can turn off the call

(At the same time $params ['rendering'] = false; and I turn off)

Does not this template nothing on the surface when erase the call, as kill by calling my_page_folder from the body at $call tag, write_page_folder (setting part), is divided into two stages of my_page_folder (database query, my_page_folder_writer call) You have


In addition, the my_page_folder (database calls), why the my_page_folder_writer (display) is divided, because it is in specification that folder plug-in it is based on is switched in setting a drawing program


So, this time for, you can customize the list by simply rewriting the my_page_folder_writer


Change of my_page_folder_writer

call argument of my_page_folder_writer, the sequence data of the corresponding page variable is passed

This time, we want to display the [embed] [status] of metadata

For now, it will rename the simple_folder.php to my_simple_folder.php

In addition, it will change the name of the header part

/* name : my_simple_folder

*/


A page variable, because the metadata is serialized, you must first uninstall serialization, and take out the status

Unserialization of metadata

$m = unserialize64($v['metadata']);

You can do you in

表示は、$m['embed']['status']

From the above

function my_page_folder_writer( &$ar )
{
	global $ut,$html,$config,$params;

	$buff = '';
	$nt = time();
	foreach ($ar as $v) {
		$t = $v['title'];
		$ico = '';
		if (!$t) { $t = '...'; }
		$u = $ut->link($v['id']);
		$m = unserialize64($v['metadata']);		// *** add my_simple_folder ***
		if ($v['type'] == PAGE_FOLDER_ID) {
			$ico = $ut->icon('folder',"width='16'");
		}
		if ($v['mode'] == 0) {
			if (!check_rights('edit') && isset($_SESSION['login_id']) && $v['user'] != $_SESSION['login_id']) { continue; }
			$t = $t.$ut->icon('lock','width="16"');
		}
		$d = substr($v['date'],0,10);
		$s = '---';									// *** add my_simple_folder ***
		if (!empty($m['plugin_embed']['status'])) {		// *** add my_simple_folder ***
			$s = $m['plugin_embed']['status'];			// *** add my_simple_folder ***
		}												// *** add my_simple_folder ***
$buff .= <<<EOT
		<p id='plugin_page_folder{$v['id']}' >
			{$ico} <a href='{$ut->link($v['id'])}'>{$t}</a> <span class='date'>{$d}</span> $s
		</p>
EOT;
	}

	return $buff;
}
   

It will fix like this


When you actually displayed, it looks like this





Google Website Translator - Google Translate