Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy. This forum is not for asking programming related questions.
I was planning on using CodeIgnitor to hammer something out quickly but it uses the same namespaces as the other framework -- which is one reason globals are bad -- but since when did CodeIgnitor care about design?
Anyways...if anyone know of a project which is a simple class that I can include (without namespace collision problems) configure and execute to generate my links for pagination...I'd appreciate it.
I've searched the boards and Google and found little of interest.
I don't want it to rely on a database connection...it should be totally independent of anything just accept the total pages, etc and generate the HTML as required.
I know it's a common subject here on DN but I'm not looking for implementation ideas I'm just interested in a single class solution...no templates, or anything fancy.
CodeIgnitor would have been perfect had it not been for the tight integration into their own framework either by ignorance or intelligent business decision who knows.
PCSpectra wrote:I don't want it to rely on a database connection...it should be totally independent of anything just accept the total pages, etc and generate the HTML as required.
I know it's a common subject here on DN but I'm not looking for implementation ideas I'm just interested in a single class solution...no templates, or anything fancy.
I don't think there is a general design to the problem of pagination that is a single class solution. However, what you describe sound like about 20-30 lines of code -- no datasource, just total pages (and page size), the the HTML you like.
I don't think there is a general design to the problem of pagination that is a single class solution. However, what you describe sound like about 20-30 lines of code -- no datasource, just total pages (and page size), the
Never said there was...how you implement is depends on a many factors/variables...although the more loosely coupled it is from dependencies, certainly the more reusable it is.
Thankfully Joomla has a pager class...I just need it to work I could care less about the elegant design in this case.
There shouldn't really be any dependencies for a pager class if my thinking is correct. All it needs is numbers... it's just a calculator for offsets and ranges.
$pagingModel = new PagingModel(count($recordSet), 25, $request->get('pagenum'));
$pagedRecordSet = $recordSet->getRange($pagingModel->getStartOffset(), $pagingModel->getEndOffset());
This assumes that your record set is not materializing records before it needs to use them, but the general approach is always this way... the paging is numbers-only. It's easy to output the links based on what getCurrentPage(), getLastPage() and getFirstPage() return.
There shouldn't really be any dependencies for a pager class if my thinking is correct.
I would be inclined to agree, however I have seen many, many many pagers which:
1. Relied on a data source (database, csv, etc)
2. Relied on a specific client view medium (HTML, etc)
Each implementation has it's advantages/disadvantages, however I usually want something simple...and in this case didn't want to implement anything, no HTML or calculations, etc...I just wanted to call a simple class and invoke it's render() like method.