Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1057153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:49:22+00:00 2026-05-16T17:49:22+00:00

Hello fellow drupalers, I have a question about ajax loaded views. Lets say i

  • 0

Hello fellow drupalers, I have a question about ajax loaded views. Lets say i have 15 items, and i have the pager to show 5. Now i want to have a button that says show “more”. when the button is pressed i want the view to load an additional 5 items in the view. So if i have lets say animals. cat,dog,panda,snake,worm,zebra,lion if the pagers is at 3 it should show cat,dog,panda. On button press it should load 3 more items, and the view should now say cat,dog,panda,snake,worm,zebra, if i press again it should show the whole list. I don’t know how to do this, someone could possibly point me in the right direction? The content is rather heavy, so a display none solution and jquery would be unacceptable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:49:23+00:00Added an answer on May 16, 2026 at 5:49 pm

    Do the ajax callback yourself but use views for the actual query.

    Set up a URL for the ajax callback in hook_menu() and then in the callback figure out which “page” is being requested and set it programatically in the callback & return just what you need.

    function general_menu() {
        $item['callback/url'] = array(
            'type' => MENU_CALLBACK,
            'page callback' => 'my_ajax_callback',
            'access callback' => TRUE,
        );
    }
    
    function my_ajax_callback() {
        $page = $_REQUEST['page'] ? $_REQUEST['page'] : 0;
        $view = views_get_view('{view_name}');
        $view->set_display('{display_name}');
        $view->set_current_page($page);
        $view->pre_execute();
        $view->execute();
        print $view->render();
        exit;
    }
    

    You’ll have to do the ajax request yourself and manage the current page on the client-side, too, but it shouldn’t be that hard. Also, you might need to override some view template files so you don’t get all the view wrappers when requesting more items, only the items themselves. When the ajax call returns you can just insert the result into the DOM below the other items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello fellow StackOverflowers. I'm have a brain fart right now, and I cannot seem
Hello fellow programmers I have been searching the internet for a few days now
Hello fellow C++ programmers. I have, what I hope to be, a quick question
Hello fellow Stackoverflow users, I have a page which does a AJAX request to
hello fellow java developers. I'm having a bit of an issue here. I have
Hello fellow programmers, I have made a function that looks up the database if
Hello fellow developers. I have previously made a facebook fan page with an iframe
Hello fellow developers... just to make sure, I want to ask this question: How
Hello fellow stackies, I'm developing a site and I have a small problem. It's
Hello fellow programmers. I have a SQL Server 2005 query that is taking a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.