I'm mostly finished the new version of the blog. One cool thing I just did was the login feature. In my framework I now have a small library that can sit on top of any database table and transparently deal with logging users in, out, and auto logging users in. Getting it to work with wordpress was a bit tricky; however, because this library is normally meant to stand alone.
The way I solved logging in to the new site and logging in to wordpress was to open a socket connection to wp-login.php and POST the appropriate form information.
Another recent addition was the pagination library that I mentioned in my last post. From the PHP side, it lets me do the following:
$response['posts_pager'] = $this->pager
->numPages($num_pages)
->currentPage($request['page_num'])
->showRightOfCurrent(3)
->showLeftOfCurrent(3)
->setPath('/page/%page%/');
An then I can use that pager from the templates with the following tags: page:open, page:first, page:prev, page:each, page:next, and page:last. If you scroll down to the bottom of the front page then you can see when/how each of these tags is used. For example, if we can see the number '1' for page one, then page:first isn't shown. If we are not on page 1, then page:prev is shown. The Pager::showLeftOfCurrent() and Pager::showRightOfCurrent() dictate the maximum number of page numbers to show on the left and right sides of the current page we are on. So, for example, if you go to the front page, you will only see up to the number 4, because there are only allowed to be 3 page numbers to the right of the current page.
Another great thing about the pagination library is that it takes a lot of the hassle out of doing pagination. One such hassle this removes is having to worry about page boundaries. In fact, you can pass it the page number information right out of the $request object and expect it all to work. Of course, its easy to make your own function to do all of this and generate HTML, but then things become trickier if you want to style different pagers differently.
I think this new version of the blog is a testament to how rapidly one can code with the PHP5 framework I am developing. Within a matter of hours I had all of the main functionality of the wordpress homepage. After another few hours, every page worked. After that the only thing left was trying to make it all look half-decent.
- Uncategorized by Peter Goodman on Jul 12, 2007 @ 10:21pm

