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 1076743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:28:35+00:00 2026-05-16T21:28:35+00:00

I have views 2 installed and I have created a view that is displayed

  • 0

I have views 2 installed and I have created a view that is displayed in the front page.

The view displays some page links ( 1 | 2 | 3 | 4 | … etc). I want to know if it’s possible to make the view start at a random page instead of always starting at page 1.

Note: I don’t want to randomize the display I really just want to randomize the page it loads.

Thanks

Possible Solution:

In the views_pre_execute hook I used this:

$view->query->pager->set_current_page([random value]);

I am not sure I can determine the number of total pages in the pager at this time but I am going to keep investigating (The $view object given in the hook has tons of properties with arrays and other objects which makes this complicated)

  • 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-16T21:28:36+00:00Added an answer on May 16, 2026 at 9:28 pm

    I do not know how to do this from the Views UI, but you should be able to achieve this using one of the views module hooks, in this case probably hook_views_pre_execute. Unfortunately, the documentation for these is practically non existing, so you’d need to implement the hook in a custom module and inspect the passed in view object via the debugger (or print, var_dump, etc. statements).

    You should look for $view->pager['current_page'], which you can set to a random page. Unfortunately, if I read the code correctly, the count query that determines the possible number of pages is not yet run at this point, so you’ll either have to use a ‘best guess’, or come up with a different way to determine the proper range to select from…

    NOTE: This is in no way meant as an ‘authoritative’ answer – just a pointer where I’d start looking, since nobody else has answered this so far. I might well be missing a more obvious/easy solution :/

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

Sidebar

Related Questions

I have an application written in C# that uses Outlook Interop to open a
I'm running Visual Studio 2008 sp1 on Win7, with MVC2 RTM installed. I created
I have a ListBox that gets populated with items read from a JSON response.
I have a layout that creates a ListActivity. Before displaying the ListActivity, I perform
I installed ActiveReports from their site. The version was labeled as .NET 2.0 build
I've have been using Visual Studio 2005, alongside Visual Web Developer 2008 to create
I'm new to CakePHP and am just running through the configuration process, but am
I'm building a recipe management system for a cooking website in Drupal, and I
I've been reading similar questions, but many of the answers are outdated or not
Solved: Unfortunately I wasn't able to solve the problem but I started over and

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.