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

  • Home
  • SEARCH
  • 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 8827451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:22:30+00:00 2026-06-14T07:22:30+00:00

I need certain pagination variables in my controller action. such as: 1.Current Page Number

  • 0

I need certain pagination variables in my controller action.

such as:

1.Current Page Number

2.Current Page offset

3.total records displayed

i.e. 31 to 40 of 2005 records displayed

I tried the following:

$dataProvider = NodesTerms::getNodesDataFromTerms($nodeId) ;     
  $pagination = $dataProvider->getPagination();
  var_dump($pagination->getPageCount());
  //var_dump($pagination->currentPage);

I can get the Pagination Object, but zero (0) in $pagination->currentPage or $pagination->offset etc….

I need this information to dynamically generate meta page title and description on actions with page listings such as pagetitle: page 3 of 10 for American Recipes…

Appreciate any help with this.

  • 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-06-14T07:22:31+00:00Added an answer on June 14, 2026 at 7:22 am

    Try setting the itemCount explicitly in your dataProvider:

    'pagination'=>array(
        'pageSize'=>10,
        'itemCount'=>$count
    )
    

    Or use a new CPagination object:

    $pagination = new CPagination($count);
    
    $dataProvider = new CSqlDataProvider($sql, array(
        // ... other config
        'pagination' => $pagination
    ));
    

    How this works:

    The pagination’s itemCount is set during creation of the data-provider and again in CSqlDataProvider‘s fetchData function:

        $pagination->setItemCount($this->getTotalItemCount());
    

    During creation of data-provider only the values passed to the pagination property are used, and if we don’t pass itemCount value, then the default of 0 is used.
    So if we want to access offset or pageCount or currentPage or itemCount before the call to fetchData we have to set the itemCount explicitly.

    However if we want those values after the call to fetchData then the values are already correctly populated due to the call to setItemCount within fetchData.

    An example for clarity (without passing itemCount during data-provider creation):

    $dataProvider = NodesTerms::getNodesDataFromTerms($nodeId);     
    $pagination = $dataProvider->getPagination();
    var_dump($pagination->getPageCount()); // this will be zero
    
    $data=$dataProvider->getData(); // getData calls fetchData()
    
    var_dump($pagination->getPageCount()); // now this will be correct value 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a certain part of current URL. Say for example the URL is:
My current thinking: I need a certain module that will let me access the
I have an 8 digit hexadecimal number of which I need certain digits to
I have about 10-20K records and only need certain cities. I would like to
Here's my current rule: RewriteRule (.*) view.php?id=$1 However, I still need certain files to
I have a number of view specs that need certain methods to be stubbed.
I need certain scripts to refire after an AJAX load. How could I accomplish
I have two objects List<Report> List<Newsletter> I need certain properties like Id Date Status
I need a certain portion of my text in RTB to be highlighted not
I need a certain portion of my text in RTB to be highlighted not

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.