Tag: book list

2009-09-22

Book List App: Using Auto-Suggest with CodeIgniter

by Charles — Categories: PHP — Tags: , , , 1 Comment

I had a couple fields on the form for adding authors/books to the DB for which I wanted to use an “auto-suggest” feature via JavaScript; one of those things where after you start typing it pops up a list of matching choices from which you can select the one you want. After trying several different scripts that I could not get to work for one reason or another, I ended up using Ajax Auto Suggest v.2.

I did, however, have to change one line of that JavaScript file in order to get it to play nicely with CodeIgniter “friendly” URLs. I just got rid of the bit that set a varname= part of the URL:

	// create ajax request
	//
	if (typeof(this.oP.script) == "function")
		var url = this.oP.script(encodeURIComponent(this.sInp));
	else
		// var url = this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp);
		var url = this.oP.script+encodeURIComponent(this.sInp);

Then when activating it within the page (CI view), I simply specified the CI URL to the controller/function with a trailing slash, to which the JS script then appends the value which my CI method will receive as its first (and only) parameter:

<script type='text/javascript'>
// <![CDATA[
	var options = {
		script:"/index.php/ajax/author_auto_complete/",
		json:true
	};
	var as_json = new bsn.AutoSuggest('author', options);
// ]]>
</script>

2009-09-17

Book List Project: Using the “Template” Pattern

by Charles — Categories: PHP — Tags: , , , Leave a comment

As part of my Book List project I am making use of the Template design pattern for my CodeIgniter database table models. The idea is that an abstract class contains the common processing needed by each class that will extend it, and it will have some number of abstract methods which essentially force each child class to set variables that differentiate each child class — in this case the database table and column names for the specific model class.

(more…)

2009-09-16

Book List Application

by Charles — Categories: General, PHP — Tags: , , 1 Comment

As something I’m doing just because I want to and as a learning experience, I’m in the beginning stages of creating a web application where users can manage data on books: books they own, books they’ve read, and books they want to read. Assuming I stick with it, I figure I’ll post occasional articles here on the progress; hopefully providing some useful information on some of the issues I encounter as well as showing how my warped mind approaches such a task.

I started thinking about this a week or two ago, and posted a thread at KindleBoards.com to get some feedback on what sort of features people might like. I’m still in the process of deciding which suggestions to embrace and which to ignore. In the meantime I’ve started to forge ahead on the database design. I find that if I get the database structure right, then the rest falls into place much more easily — as opposed to making the database design fit my application code. My first major snag is trying to figure out how to deal with the fact that book titles are not unique (titles cannot be copyrighted). For details on that issue, I just started a thread at PHPBuilder.com, hoping some database expert will have a magical solution for me.

About the only firm decision at this point is that the app will be built upon the CodeIgniter framework, simply because I’m used to it, and it works. I’ve done some preliminary layout work for the front end, and have been making progress on using the Amazon.com Product Advertising API to (hopefully) provide a simple means for users to add books to their lists via a simple drag-and-drop of a URL from an Amazon web page. Unfortunately for us Amazon Kindle users, the Amazon database is currently not playing nice with Kindle books, so for now it’s limited to print book pages.

More to come soon, I hope….

© 2012 PHP Musings All rights reserved - Wallow theme v0.46.4 by ([][]) TwoBeers - Powered by WordPress - Have fun!