PHPackages                             bartonlp/updatesite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bartonlp/updatesite

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bartonlp/updatesite
===================

PHP helper for SiteClass

1(8y ago)437MITPHPPHP &gt;=5.4

Since Mar 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bartonlp/updatesite)[ Packagist](https://packagist.org/packages/bartonlp/updatesite)[ RSS](/packages/bartonlp-updatesite/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Update 2022-10-09: This is quite old.
=====================================

[](#update-2022-10-09-this-is-quite-old)

**I no longer support the *sqlite3* database in my SiteClass**.
**If you want to use this you will need to do some WORK.**

UpdateSite Class
================

[](#updatesite-class)

This class works with **SiteClass**. It creates sections or articles that can be placed within a webpage. The articles can be edited via a web browser and they are maintained in a database (MySql is prefered). Check out [SiteClass Documentation and Examples](https://bartonlp.github.io/site-class).

Install
-------

[](#install)

You can either **clone** the repository or you can use **composer** to install **UpdateSite**.

If you do not have **composer** you can get it at . Just follow the instruction to install it globally.

Once you have **composer** select a directory where you want your repository and enter:

```
composer require bartonlp/updatesite dev-master
```

How It Works
------------

[](#how-it-works)

The sections are stored in a database. Currently there are two databases the **SiteClass** supports:

- MySql. This uses the most current PHP library (mysqli)
- Sqlite2. This is not as well tested but should work with **UpdateSite**

The database schema for MySql looks like this:

```
CREATE TABLE `site` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `page` varchar(255) NOT NULL,
  `itemname` varchar(255) NOT NULL,
  `title` varchar(255) DEFAULT NULL,
  `bodytext` text,
  `date` datetime DEFAULT NULL,
  `status` enum('active','inactive','delete') DEFAULT 'active',
  `lasttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `creator` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
```

The 'creator' field is only used if you have extended the **SiteClass** to handel members.

You can create a webpage as follows:

```
// test.php
// See the SiteClass documentation
$_site = require_once(getenv("SITELOAD"). "/siteload.php");
$S = new $_site->className($_site);

// The following comment is needed by UpdateSite.
// This must be at the beginning of the line and have the words 'START UpdateSite'
// followed by the name of the database item. This can be anywhere in the file but
// I like to put it close the the invocation of UpdateSite.

// START UpdateSite Message
// START UpdateSite AnotherMessage

$s->siteclass = $S; // This is the SiteClass object or one of its children
$s->page = "test.php"; // The name of the page
$s->itemname ="Message"; // The name of the database item

$u = new UpdateSite($s); // instantiate the class

$item = $u->getItem(); // gets the item in 'itemname'. You can set a different value and then call with $s.

// If item is false then no active item in table

if($item !== false) {
  $message = itemname = "AnotherMessage"; // set $s with a different name
$item = $u->getItem($s); // call getItem($s) with the new itemname.

if($item !== false) {
  $anotherMessage = getPageTopBottom();

echo
