
0.5.1
20011013
weblog / news publishing tool
requirements - installation
- template(s) - querystring
usage - notes
requirements:
PHP4
MySQL
Perl (only for the spellchecker)
...and a link to http://b2.dayzero.org
on your site.
The link is not necessary, but it's greatly appreciated, and it helps
spreading the word about b2. I'm coding this on my free time, and spending
a lot of time listening to users' feedback and suggestions, to make it
a great tool, yet I give it away for free, so I'd like some credit. Thanks
for your understanding.
installation:
New users:
1. Unzip the package in an empty directory.
2. Open b2config.php in a text editor, and modify the variables
as explained.
3. Upload everything except the /spellchecker directory, and the
db-upgrade files. This release is designed to sit in your root folder,
IE the folder where your b2-powered page will reside.
4. This isn't necessary but ensures your security: With your FTP
program, do a CHMOD 644 on the file b2config.php, so no-one can overwrite
it except you. If your server is on Windows NT, then set the file on "read-only"
mode.
5. Launch b2install.php in your browser. This should setup the
MySQL database for your blog. If there is an error, double check your
b2config.php file, and try again. If it fails again, please go to the
support forums there: http://dayzero.org/boardom,
and make a post with all the information about the failure (error messages,
etc), and your setup (the PHP and MySQL versions on your server, and the
browser you were using).
6. IMPORTANT: Delete b2install.php - this is not necessary since
v0.5, because there's no "drop table" instructions in the install
script anymore, but it's better to delete it anyway (or rename it to a
random name in case you need it again in the future).
7. Go to b2login.php and log in with the login "admin"
and the pass "admin". Then go to the Team page, and click on
your login name "admin", and change the admin's password. Note:
you need javascript enabled to launch the profile popup window.
8. Do this if you don't want to blog as "admin": log
out, create an user account on b2register.php, then re-log in as "admin",
and update the level of the new user to 5 or more, so that you have all
the admin rights. Logout, then log in as the new user.
9. Whenever you want to post something, just open a browser and
go to b2login.php to log in and post. Your site's blog is on b2.php, you
can rename this file to index.php or any other name you fancy (provided
it bears the php extension or is interpreted as a php file by your server).
Installation of the spell checker:
10. Upload the /spellchecker files in a directory where you can
execute CGI scripts.
11. Open sproxy.ini, and change the "Main configuration variables".
12. If you haven't done it yet, change the spellchecker variables
in the b2config.php file.
13. Do a CHMOD 755 on the sproxy.cgi file. The spellchecker might
work now :)
Users upgrading from v0.5 to v0.5.1:
1. Unzip the package in an empty directory, to avoid
deleting your existing b2config.php file.
2. Open your b2config.php file, and add a line that says: $blogname = "the name of your blog"; That is used for the bookmarklets and is likely to be used in more things in the future.
3. Edit all your templates and update your template tags
to follow the new template tag system here, because there have been some
modifications, and it would cause some errors if you didn't edit the templates.
Tags noted with an orange asterisk *
are tags that were added or modified in v0.5.1, these are those you got
to update in your templates.
template(s):
First notes:
Enclosed is an example of a template, in the file b2.php. You can rename
this file to "index.php".
You can have any number of template files, since all they do is extract
the posts from the database.
Template for the comments is in b2comments.php. You needn't rename this
file.
The only thing to remember is that it's not actually a template, but a
PHP file that you're manipulating. So when you see "don't delete
this line", you know you mustn't, unless you want to have a broken
page.
Required lines are: the first lines that call blog.header.php, the lines
with the "while" statement, and the ones with just "}"
(it ends the while loop).
Between the "while" line and the "}", is the template
for your posts.
Template tags are these:
<?php the_date() ?>
the date of the post. example: 03.07.01 (default is dd.mm.yy).
the date is displayed only on new days. for example if you got 10 posts
on the same day, the date for this day is displayed only once.
<?php the_time() ?>
the time of the post. example: 18:37:00 (default is hh:mm:ss)
Note: you can change the way the date & time are displayed
in the Options page.
once you understand the format strings for the date & time (explained
in the Options page), you can change the display right on the template:
for example, the_date("d.m.Y") to have
dates like 25.12.2001, the_time("B") to
have Swatch Internet Time.
Note about the_date(): if you want all your posts to bear the date,
you'll have to use the_time() instead, with a date format string. for
example, to have all your posts show like "25.12.2001 @ 8:04:50 AM"
you'll have the_time("d.m.Y @ g:i:s A"). you can also repeat
this template tag 2 times with 2 different formats: the_time("d.m.Y")
for the date, and then later the_time("g:i:s A") for the time
of the day.
<?php the_weekday() ?> *
This displays the day of the week when the post was made. It works like
the_time(), in that it would appear at every post. Weekdays can be obtained
with a custom date format string in the_time() or the_date(), but for
non-english weekdays you have to edit b2config.php
<?php the_weekday_date() ?> *
Like the_weekday(), but works like the_date(), in that it would appear
only on new days.
<?php the_ID() ?>
the ID (number) of the post.
<?php the_title() ?>
The title of the post.
<?php the_content() ?> *
The text of the post.
You can pass some variables there, for extended entries, in this order:
- the text to display for the link to the complete entry. Default is '(more...)'
- 0 or 1, whether you want to show the teaser message or not, when showing
the complete text. Default is 1.
- a filename of another template, if you want the 'more' link to link
to a different template for the complete text of the extended entry. Default
is the current template.
For example <?php the_content("read more","0","blah.php")
?> would display a link to blah.php, with the link text
read more, and won't display the teaser message.
*
To enter an extended entry, just type <!--more--> in your
entry. The part before that comment is the teaser, the part after it is
the extended entry. To force the extended entry not to show the teaser
message, type <!--noteaser--> somewhere in your entry.
<?php the_author() ?>
The author of the post.
Depending on the user's profile settings, it can display whether their
nickname, login name, first name, last name, both first& last name,
or last & first name. look below for more author-related template
tags.
<?php the_category() ?>
the name of the category the post belongs to. you can as an admin
add categories, and rename them if needed. default category is 'General',
you can rename it too.
<?php the_category_ID() ?>
The ID (number) of the category the post belongs to. This is static
data thatyou can use, for example to associate a category to an image,
or a css style.
<?php dropdown_cats() ?>
this is a special tag, meant to be used in the template, but outside of the b2 loop. it will display a list of <option name="x">category-name</option>, where x is the number of the category and category-name is the name of it.
you should use it like this:
<form action="<?php echo $PHP_SELF ?>" method="get">
<?php dropdown_cats() ?>
<input type="submit" name="submit" value="view" />
</form>
<?php list_cats() ?>
this is a special tag, meant to be used in the template, but outside of the b2 loop. it will display a list of the categories, with links to them. like in b2archive.php, each category is on a line, the only way you can change this is by editing b2.template.functions.php
More about the author of the post ? Here goes:
<?php the_author_email() ?> - the author's email.
<?php the_author_url() ?> - the author's url.
<?php the_author_email() ?> - the author's number of posts.
<?php the_author_icq() ?> - the author's ICQ number.
<?php the_author_aim() ?> - the author's AIM handle.
<?php the_author_yim() ?> - the author's Yahoo Messenger
handle.
<?php the_author_msn() ?> - the author's MSN Messenger handle.
<?php the_author_posts() ?> - the author's post count.
<?php the_author_login() ?> *
- the author's login name in b2. If you want some static data about the
author, this is what you're searching for. You can, for example, associate
a picture with an author, like this: <img src="pictures/<?php
the_author_login() ?>.jpg" border="0">
<?php the_author_ID() ?> *
- the author's ID number in b2. This number is automatically set when
the user registers: to see the ID of an user, go to the Team page. This
is static data too, so you can use it like the_author_login() in associating
stuff with authors.
Tags for permalinks are:
<?php permalink_anchor() ?>
this will display <a name="..."></a>, replacing
"..." with the ID of the post in the database.
<?php permalink_link() ?> *
this will display the name of the file followed by #ID to link to
the post, in the month archive if archive-mode is "monthly".
note: this tag does not display the link, for this you've got to type
<a href="<?php permalink_link() ?>">text of the
link</a>.
<?php permalink_single() ?> *
this will display the name of the file followed by #ID to link to
the entire post (the linked page will also show the comments on that post).
note: this tag does not display the link, for this you've got to type
<a href="<?php permalink_single() ?>">text of the
link</a>.
You can now include a filename, complete with folders if you want. Example:
<?php permalink_link("single_post_template.php"
) ?> (same method applies to the permalink_single() tag)
Tags for comments are:
<?php comments_link() ?>
This is a bit like permalink_link, it will display an URL to the
comments page, but again you'll have to create the link tag.
<?php comments_number() ?> *
This displays the number of comments that have been posted on this post.
Example: "5 comments".
The three strings that you can include are there to customize the display,
in this order:
- the string for comment-less posts. Default is "no comment"
- the string for posts with one comment. Default is "1 comment"
- the string for posts with 2 or more comments. Default is "% comments".
Note here that the sign "%" is then replaced by the number of
comments.
Example: <?php comments_number("no comment","1 comment","%
comments") ?>
This tag differs from v0.5's tag because in v0.5 and prior, it would only
display a number, not a text with it, so you could have terrible things
like "1 comments" (doh !)
Necessary: <?php include("b2comments.php") ?>
you'll put this line where you want the comments to be placed on your
page.
typically, under the post itself. don't worry, the comments only appear
if the page is called in the comments mode. (like this: url?c=1)
Tags that go in b2comments.php: (these are easy too)
<?php comment_author() ?>
<?php comment_author_email() ?> - displays the e-mail address,
but not the link
<?php comment_author_url() ?> - displays the url, but not the
link
<?php comment_author_IP() ?> *
- displays the IP of the comment's author (new in v0.5.1)
<?php comment_text() ?>
<?php comment_date() ?> - unlike the_date(), this tag
appears on every comment
<?php comment_time() ?>
In b2comments.php, like in the main template file, please keep the first
PHP lines, the "while" lines, and the "}" lines.
You can modify the form, but do not remove "<?php echo ... ?>"
and all the name="..." attributes.
To include your archives:
<?php include("b2archives.php") ?>
this will include the links to your archives, one link per line.
if your archive mode is "monthly", it will display the names
of the months and the years, like "july 2001".
if your archive mode is "post by post", it will display the
titles of your posts, one title per line. if a post is untitled it will
display the ID (number) of this post.
usage:
b2 relies a lot on the querystring, these variables passed with the URL
(note: to pass variables in the querystring, preceed the first variable
name with a '?' question mark and every other variables with a '&'
sign.)
Most of the time you won't have to do anything about it, but if you want
to know how it works, it's here:
How to use the QueryString:
index.php?m=200107 will display the month of July 2001.
index.php?p=50 will display the post labeled #50 in the database.
index.php?s=blue+house will display the posts that match the
search request "blue house".
here is the code for a simple search box:
<form name="searchform" action="<?php echo
$PHP_SELF ?>" method="get">
<input type="text" name="s" />
<input type="submit" name="submit" value="search"
/>
</form>
index.php?cat=1 will display posts of the category labeled #1 (1
is the default). you can add categories and rename them, but at the moment
you cannot delete them.
index.php?withcomments=1 or ?c=1 will display the comments
and a form to add a comment below each post.
you should use this variable only with p=, example: index.php?p=50&withcomments=1.
index.php?more=1 will display the extended entries' text. this,
too, should be used only with p=, for individual entries.
You can also mix these variables, example: index.php?m=2000107&s=hotdog
will display the posts that match the search request "hotdog",
but only in July.
notes:
On multi-user:
You don't invite users, they can register on b2register.php.
Then you (as an admin) click the "+" next to their name in the
user-list, to upgrade their level to 1 or more, so they can post. If you
don't want an user to post anymore, just click "-" until their
level is 0.
Levels are these:
0 - new user: can't post.
1 - user: can post & edit/delete their own posts.
3 & more - admin: can post, edit/delete other people's posts, and
change the options.
Any user whose level is higher than 1, can edit/delete the posts and change
the level of users whose level is inferior. Example: a level 2 user is
not an admin, but can edit the posts of level 1 users, and up the level
of a new user from 0 to 1.
Usually, you'll want to have a team of only level 1 users except you.
;)
Note: you can modify a variable in b2config.php, to enable new
users to post once they've registered.
If you don't want users to register on your blog, just delete b2register.php
once you've registered your user account.
Final notes:
b2 is functionnal, but a lot of coding and code clean-up remain
to be done.
If you've got suggestions, ideas, or comments, or if you found a bug,
why not joining us in the Forums
?
If you can code in PHP, you'll see the structure of b2 is flexible enough
to allow for more functions and sections to be added.
Copyright notes:
b2 is ©2001 Michel Valdrighi - m@tidakada.com
- http://tidakada.com
Wherever third party code has been used, credit has been given in the
code's comments.
|