Hi,
at first you to install the snippet:
Before using the snippet, you have to decide wether to change the snippet code or Etomites index.php. If you would use my captcha functions, read
this thread and do what I'm describing there. Otherwise, change the following lines:
Line
55: change
$etomite->getCaptchaCode to
$etomite->getCaptchaNumber
Line
110: change
$etomite->validCaptchaCode to
$etomite->validCaptchaNumber
Create a snippet, call it as you like and paste the snippet code inside. Now I'll explain the options (can be found at the top):
-
$gbookFolder : set to the folder where the entries should be stored and read from, you will be able to edit them as you like, because the entries will be stored as ordinary documents
-
$entriesPerPage: set the number of entries per page
-
$thxPageId: you have to create this page. Place a polite text on int (for example: Thanks for your entry)
-
$repostProtection: set to the seconds a visitor which just created an entry has to wait to create a new one
-
$minCaptchaLength: set to the minimal length of the captcha text
-
$maxCaptchaLength: set to the maximal length of the captcha text
-
$maxURLLength: maximal length of an url before it is shortened, unit: chars. If a url is too long, it will be shown as 'http://www.etomite...'.
The guestbook makes heavy use of chunks to make you able to get a visual customizable output, so at first you need to create some chunks. Use the exact names, or change them in the appropiate line of the snippet.
I've attached the set of my chunks, of course you can use them if you will. If you want to create you own, here are the placeholders for the chunks:
Chunk:
kgbook-alreadyEntered will be shown if the person had just created one entry
No placeholders. Enter a message in pure html, for example: To avoid multiple entries, you are now only allowed to read the existing entries.
Chunk:
kgbook-entrydisplay holds one entry
-
%name%: name of the entry creator
-
%mail%: email of the creator
-
%weburl%: webadress of the creator
-
%message%: the entry
-
%datetime%: date and time of the creation
-
%number%: entry number
Chunk:
kgbook-newentryfrm contains the new entry from
-
%actionurl%: the action url of the form
-
%captcha%: <img> tag of the captcha
-
%maxcaptcha%: maximal captcha length
Chunk:
kgbook-pagenavigation creates the page navigation
-
%entrycount%
-
%currentpage%
-
%pagecount%
-
%firstpage%: a complete link (<a href="">...) to the first page
-
%prevpage%: a complete link (<a href="">...) to the previous page
-
%nextpage%: a complete link (<a href="">...) to the next page
Chunk:
kgbook-summary summary of the guest book
-
%entrycount%
-
%currentpage%
-
%pagecount%
To customize the output itself (for example, you would like to have the new entry formular at the bottom), edit the code below line 258, documentation is in the snippet.
Not needed for Etomite 0.6.1 final!
A small patch for the makeURL function:
If you use Etomite not at the top directory of your domain, you can get problems when a visitor successfully creates an entry, because the snippet redirects to a thank you page. For this, I'm using Etomite. If you get errors and you are using etomite not at the top directory of your domain (for example
http://www.kgbookist...nearth/etomite/), than apply this patch to your index.php.
Be carefull, I'm using it, but test it before you will use it too!
Replace the code between line 1434 and line 1443
if(!is_numeric($id)) {
.
.
.
return $this->config['site_url']."/"."index.php?id=$id$args";
} with this one:
if(!is_numeric($id)) {
$this->messageQuit("`$id` is not numeric and may not be passed to makeUrl()");
}
if($this->config['friendly_alias_urls']==1 && isset($this->aliases[$id])) {
$genURL = $this->config['site_url']."/".$this->aliases[$id].$this->config['friendly_url_suffix'].$args;
return (dirname($_SERVER['PHP_SELF']) == '/') ? $genURL : $etomite->config['site_url'].dirname($_SERVER['PHP_SELF']).substr($genURL, strrpos($genURL, '/'), strlen($genURL));
} elseif($this->config['friendly_urls']==1) {
$genURL = $this->config['site_url']."/".$this->config['friendly_url_prefix'].$id.$this->config['friendly_url_suffix'].$args;
return (dirname($_SERVER['PHP_SELF']) == '/') ? $genURL : $etomite->config['site_url'].dirname($_SERVER['PHP_SELF']).substr($genURL, strrpos($genURL, '/'), strlen($genURL));
} else {
$genURL = $this->config['site_url']."/"."index.php?id=$id$args";
return (dirname($_SERVER['PHP_SELF']) == '/') ? $genURL : $etomite->config['site_url'].dirname($_SERVER['PHP_SELF']).substr($genURL, strrpos($genURL, '/'), strlen($genURL));
}
Important: Patch for Etomite 0.6.1 (and above)!
Change line 56 of the snippet from
$gbookCaptcha = $etomite->getCaptchaCode(rand($minCaptchaLength, $maxCaptchaLength), 'captcha code', 'captcha Code');
in
$gbookCaptcha = $etomite->getCaptchaCode();
.
Otherwise you'll get display problems with some browsers (see posts from
smartie below).
Have fun with the guestbook.
Greetings, Kastor
Edited by kastor, 22 September 2006 - 01:47 PM.