brentxscholl's avatar

Pagination not working in Forge, but works on local machine

I'm using Laravel 4.2.16 simplePaginate in my project to create a facebook style image viewer. On my local VM it works flawlessly. However, when I install my repository onto my live server using forge, this is the only thing on the site that now does not work.

On my live server the next & prev links are not showing.

I'm using a custom pagination layout.

Here is my code: Controller

public function imageViewer($id)
    {
        $images = $this->mediaRepository->getPaginatedImages($id);
        return View::make('image-viewer', compact('images'));
    }

// media repository
public function getPaginatedImages($id)
    {
        $post = Resource::where('id', $id)->first();
        return Media::with(['comments' => function($query) {
            $query->with('likes');
        }])->with('likes')->where('resource_id', $post->id)->simplePaginate(1);

    }

View

      <div class="image-viewer-image">
            <div class="image-viewer-image-container">
        <!-- *** Im using UIKIT (css bootstrap), uk-overlay is a container for the hidden uk-overlay-area, this hides the div until the user mouses over it. this all works on local machine *** -->
                <div class="uk-overlay">
                    <img src="{{ URL::asset("images/users/{$image->url}") }}" class="scale" data-scale="best-fit-down" data-align="center">
                    <div class="uk-overlay-area">
                        {{ $images->links('php_includes.pagination.slider') }}
                    </div><!-- uk-overlay-area end -->
                </div><!-- uk-overlay end -->
            </div><!-- image-viewer-image-container -->
        </div><!-- image-viewer-image end -->

Here is the php_includes.pagination.slider view:

<?php
    $presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
    $trans = $environment->getTranslator();
?>
<?php if ($paginator->getLastPage() > 1): ?>
    <ul class="image-viewer-prenext-container">
        <?php
            echo $presenter->getPrevious($trans->trans('pagination.previous'));
            echo $presenter->getNext($trans->trans('pagination.next'));
        ?>
    </ul>
<?php endif; ?>

within my vendor/laravel/framework/src/illuminate/Pagination/BootstrapPresenter.php i have

<?php namespace Illuminate\Pagination;

class BootstrapPresenter extends Presenter {

    /**
     * Get HTML wrapper for a page link.
     *
     * @param  string  $url
     * @param  int  $page
     * @param  string  $rel
     * @return string
     */
    public function getPageLinkWrapper($url, $page, $rel = null)
    {
        $rel = is_null($rel) ? '' : ' rel="'.$rel.'"';

        return '<li><a href="'.$url.'"'.$rel.'><div class="image-viewer-'.$page.'"></div></a></li>';
    }

    /**
     * Get HTML wrapper for disabled text.
     *
     * @param  string  $text
     * @return string
     */
    public function getDisabledTextWrapper($text)
    {
        return '<li class="disabled"><div class="image-viewer-'.$text.'"></div></li>';
    }

    /**
     * Get HTML wrapper for active text.
     *
     * @param  string  $text
     * @return string
     */
    public function getActivePageWrapper($text)
    {
        return '<li class="active"><div class="image-viewer-'.$text.'"></div></li>';
    }

}

Like i said before this pagination work on my local machine, but when its on my live server with laravel forge this is the only thing on my site that no longer works.

Here is a comparison of the code using firebug:

Local machine: http://s15.postimg.org/idjl5kl5n/localmachine_pag.png

Live Server: http://s3.postimg.org/p67ay5npf/liveserver_pag.png

The main differences I see is within the <ul> it's not picking up the changes I made in vendor/laravel/framework/src/illuminate/Pagination/BootstrapPresenter.php

Anyone have any ideas why this is happening? let me know if I need to post more code.

0 likes
1 reply
brentxscholl's avatar

Im not sure if this is a correct fix but in my .gitignore file I removed /vendor so my vendor/laravel/framework/src/illuminate/Pagination/BootstrapPresenter.php is added

It all works now

Please or to participate in this conversation.