Jump to content

pagination and role


Frank Vèssia
 Share

Recommended Posts

I have two roles in my website, "standard" and "premium".

Standard users can access only to a certain numbers of "reports" rows in a table format, paginated, Premium users can access all report.

I want to block the pagination and show only the page numbers for each type of users, now pagination refer to the total pages of a selector. Is there a way to do this?

Link to comment
Share on other sites

If I'm understand right, you want to have to different paginations?

Like if I'm "standard-user" I'll see this

[tt]

-Home

-About

[/tt]

And if I'm "premium-user" I'll see this

[tt]

-Home

-About

-Hidden for standards

[/tt]

Well, maybe you could make a if statement?

I'll think this might work...

Like this:

if($user->hasRole('standard')){
//Your code to get the pages that have standards-permissions
}
elseif($user->hasRole('premium')){
//Your code to get the pages that have premium-permissions
}
else{
echo 'You dont have access to this';
}

Link to comment
Share on other sites

I want to block the pagination and show only the page numbers for each type of users, now pagination refer to the total pages of a selector. Is there a way to do this?

I'm not sure that I understand the question well enough. If you are using PW's built-in access control, then the pagination should be consistent with the pages the user has access to. But if you instead want it to include the pages the user doesn't have access to, you'd want to add "check_access=0" to your selector that does the $pages->find() or $page->children().

Link to comment
Share on other sites

I cannot control pagination with role access because those pages are statistics pages and the template is unique.

Every user can submit a link, this link will be a pw page.

If you are Standard user you cannot see all links submitted (generated pages) because your account is limited in how many links you can see, it's not a question of permissions. So when i render these pages in a list format i want to limit the total pages the pagination calculate, using "limit=10" in selector don't affect the total pages of course.

Sorry, i'll try to make a simple example:

100 pages, same template. Using a selector like "limit=10" will return to me 10 pages. I want to show only the first 5 pages to a particular user because that user can see only 50 pages.

Something like using first "limit=50" and than again "limit=10" for getting the pagination.... :-\

Link to comment
Share on other sites

I think I understand. Try modifying the settings carried by the PageArray after your find() is performed, but before your pagination is output:

<?php
$results = $pages=find("something=something, limit=10"); 
if($user->isGuest() && $results->getTotal() > 50) {
    $results->setTotal(50); 
    if($results->getStart() > 40) $results->setStart(40); 
}
// then do your pagination
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...