Giter VIP home page Giter VIP logo

Comments (12)

parndt avatar parndt commented on August 12, 2024

@dkabistan frontend or backend?

from refinerycms-page-images.

denisinla avatar denisinla commented on August 12, 2024

@parndt This would be on the front-end, currently I'm displaying 20 images on the front-end without pagination(long scroll). Any ideas as to how to paginate, after roughly 5 images?

from refinerycms-page-images.

parndt avatar parndt commented on August 12, 2024

This extension purposefully stays out of the frontend code so I'm afraid this is up to you. I would suggest using a pagination plugin like will_paginate as refinerycms-core already depends on it.

from refinerycms-page-images.

denisinla avatar denisinla commented on August 12, 2024

@parndt Does that mean that I can't override the pages-images controller to add paginate with limit amount. If so please advise naming, since I've exhausted finding it.

from refinerycms-page-images.

parndt avatar parndt commented on August 12, 2024

@dkabistan there is no page-images controller.. All this extension really does is add an images relationship to refinerycms-pages and also a backend UI for managing that relationship inside the page's form.

So, on the frontend, you can refer to it using @page.images (assuming you have a @page variable.. which you usually will)

How are you currently using this extension on the frontend?

from refinerycms-page-images.

denisinla avatar denisinla commented on August 12, 2024

@parndt following the same implementation as refinerycms-page-images except using a custom view template. I was not aware of it being this simple. I'll try out using will_paginate.

Thanks !

from refinerycms-page-images.

parndt avatar parndt commented on August 12, 2024

@dkabistan no problem.. if you have any trouble, feel free to post again to here. I just closed the issue as it's not an "issue" with the extension but am happy to help if I can.

from refinerycms-page-images.

denisinla avatar denisinla commented on August 12, 2024

@parndt I followed the wiki to initiate pagination for @page.images on the front-end, the pagination works but the per_page limit set is not picked up. Any ideas?

<%= render '/refinery/content_page' %>
<section id="box">
  <article class="content">
    <% @page.images.each_with_index do |image, index| %>
      <figure class="press-item">
      <%= link_to image_tag(image.thumbnail(geometry: '242x316').url),
                            image.thumbnail(geometry: '900x600').url,
                            class: 'fancybox',
                            rel: 'gallery'
      %>
        <figcaption><%= raw @page.caption_for_image_index(index) %></figcaption>
      </figure>
    <% end %>
  </article>
  <%= will_paginate @page.images.paginate :page => params[:page], :per_page => 5 %>
</section>

from refinerycms-page-images.

parndt avatar parndt commented on August 12, 2024

@dkabistan given you're calling a will_paginate helper it should be working like this, according to the docs.

You could try adding brackets?

<%= will_paginate @page.images.paginate(:page => params[:page], :per_page => 5)

from refinerycms-page-images.

denisinla avatar denisinla commented on August 12, 2024

Turns out I needed to define paginate usage on an array(d'oh): Stackoverflow Thread

will_paginate 3.0 is designed to take advantage of the new ActiveRecord::Relation in Rails 3, so it defines paginate only on relations by default. It can still work with an array, but you have to tell rails to require that part.

In a file in your config/initializers/will_paginate_extension.rb, add this

require 'will_paginate/array'

Then you can use on arrays

my_array.paginate(:page => params[:page], :per_page => y)

from refinerycms-page-images.

parndt avatar parndt commented on August 12, 2024

@dkabistan woohoo 👍

from refinerycms-page-images.

denisinla avatar denisinla commented on August 12, 2024

@parndt I'm having a bit of an issue figuring this one out. I have successfully paginated my images on the front-end but for some reason my captions are not in sync when you click on the next page.

I've tried adding paginate to @page.caption_for_image_index(index) but unsuccessfully. Any ideas how to go about?

from refinerycms-page-images.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.