Zend Paginator & Doctrine

Satt igår och jobbade på ett projekt där jag använder mig av Doctrine & ramverket Zend. Självklart ville jag använda mig av någon typ av paginator för att smidigt kunna dela upp mina modeller på flera sidor.

library/App/Paginator/Adapter/Doctrine.php
class App_Paginator_Adapter_Doctrine
    implements Zend_Paginator_Adapter_Interface
{
    protected $_select;

    public function __construct( Doctrine_Query $select )
    {
        $this->_select = $select;
    }

    public function getItems($offset, $itemCountPerPage)
    {
        return $this->_select->offset($offset)->limit($itemCountPerPage)->execute();
    }

    public function count()
    {
        return $this->_select->count();
    }
}
application/controllers/IndexController.php
class IndexController extends Zend_Controller_Action
{

    public function indexAction()
    {
        /**
         * Paginator
         */
        $adapter = new App_Paginator_Adapter_Doctrine(Doctrine_Query::create()->select()->from('Model_Foo f'));
        $paginator = new Zend_Paginator( $adapter );
        $paginator->setItemCountPerPage( 5 )
                  ->setCurrentPageNumber( $this->_getParam( 'page', 1 ) )
                  ->setPageRange( 8 );

        $this->view->paginator = $paginator;
    }
Publicerat i Doctrine, Tips & Trix, Zend | Taggat , , | Lämna en kommentar

Zend & Doctrine, problems with charset

Recently i ran in to a problem with my charset when i used the Zend and Doctrine libraries to develop my project. I finaly managed to solve my problem and posted a topic about it in the Zendcast-forum.

Check it out over here!

Publicerat i Doctrine, PHP, Zend | Lämna en kommentar

Improved Thematic Localization

If you haven’t already tried the wonderful Worpress theme framework Thematic, I really suggest that you do so!

Thematic is a free, open-source, highly extensible, search-engine optimized WordPress Theme Framework featuring 13 widget-ready areas, grid-based layout samples, styling for popular plugins, and a whole community behind it. It’s perfect for beginner bloggers and WordPress development professionals.

Localization

As I’m from Sweden I want all parts of my web page to be in Swedish, off course! But what I found was that the localization for Thehmatic wasn’t 100%. For instance, the value of the search box did not translate correctly. Instead of being in Swedish it was in English.

And this is how I fixed it, It might just be an easier way. If so, please leave a comment ant tell me.

Läs mer

Publicerat i Guider, PHP, Wordpress | Lämna en kommentar