Pages are endless!

Started by Zozma at Mar 18, 2021 at 6:50 pm
250 Views
5 Posts


Zozma

Trash Mammal

Patron

36Years Young
38 Posts

I'm not sure if I should keep making new topics for new issues?

But how do I get the pages to not be super duper long.

I want to go from this:

 

 

To this:

 


user posted image



Arceus

codemancer

Admin

31Years Young
130 Posts

They don't think that I listen, oh but I know who they are.


Mmm without editing the core files, unfortunately you'll have to do some CSS hacks to change this. Some variant of nth-child should do it...

.page-item:nth-child(n+6) { display: none; }

That ought to do it. You will lose your next button but I don't think it'll matter too much...

Wait no that won't work either because it won't change which numbers are - see you should've hosted with me this would've been an easier fix WITH CORE ACCESS.

Anyway, so instead what you'll do is

.page-item.nomobile { display: none; }

It'll hide all of the page links and just leave you previous and next. That's the best I can do, sorry. I didn't account for people running threads that long.


Watching you bloom in the light of the moon;

Check out my writing blog! All of my fanfiction and eventually my original stories are published here.



Arceus

codemancer

Admin

31Years Young
130 Posts

They don't think that I listen, oh but I know who they are.


Actually hang on that's in the frame.template.php, you can get to that, I might be able to give you a code that restricts page display. Gimme til tomorrow to fiddle with it, I have a dentist appointment tomorrow morning so it may not be til afternoon BUT.


Watching you bloom in the light of the moon;

Check out my writing blog! All of my fanfiction and eventually my original stories are published here.



Arceus

codemancer

Admin

31Years Young
130 Posts

They don't think that I listen, oh but I know who they are.


Alright, I broke my board for you (!!!! xDDD) but I have a solution for this. In Salerno, the page counts are in the core files in Ananke, and I got used to that working on Salerno, but they are not there in Athens! So you'll get into frame.template.php and find the function template_pages(). Delete the entire thing.

Replace it with this.

function template_pages()
{
      global $text, $page, $settings;
      
      if(empty($page->pages))
            return false;
                  
            $pages = $page->pages;
            $total = $pages->total;
            $limit = 5;
            
            $arry = '';
            $arry .= '
            <nav aria-label="'.$text->label->pages.'">
                  <ul class="pagination">
                        <li class="page-item"><span class="page-link">'.$text->label->pages.'</span></li>';
                        
                        if(!empty($pages->previous))
                              $arry .= '
                        <li class="page-item"><a class="page-link" href="'.$settings->url.'/'.$pages->href.'/'.$pages->previous.'">'.$text->label->previous.'</a></li>';
                        
                        if($pages >= 1 && $pages->current <= $total)
                        {
                              $counter = 1;
                              if($pages->current > ($limit/2))
                                    $arry .= '
                                    <li class="page-item'.(1 == $pages->current ? ' active' : '').'">
                                          <a class="page-link" href="'.$settings->url.'/'.$pages->href.'/1">1</a>
                                    </li>
                                    <li class="page-item">
                                          <a class="page-link">...</a>
                                    </li>';
                              
                              for($x=$pages->current; $x <= $total; $x++)
                              {
                                    if($counter < $limit)
                                          $arry .= '
                                          <li class="page-item'.($x == $pages->current ? ' active' : '').'">
                                                <a class="page-link" href="'.$settings->url.'/'.$pages->href.'/'.$x.'">'.$x.'</a>
                                          </li>';
                                          $counter++;
                              }
                              
                              if($pages->current < $pages->total - ($limit/2))
                                    $arry .= '
                                    <li class="page-item">
                                          <a class="page-link">...</a>
                                    </li>
                                    <li class="page-item'.(1 == $pages->current ? ' active' : '').'">
                                          <a class="page-link" href="'.$settings->url.'/'.$pages->href.'/'.$pages->total.'">'.$pages->total.'</a>
                                    </li>';
                        }
                        
                        if(!empty($pages->next))
                              $arry .= '
                        <li class="page-item"><a class="page-link" href="'.$settings->url.'/'.$pages->href.'/'.$pages->next.'">'.$text->label->next.'</a></li>';
            $arry .= '
                  </ul>
            </nav>';
            
            echo $arry;
}

This should give you this:

(See how I broke it? XDDD)


Watching you bloom in the light of the moon;

Check out my writing blog! All of my fanfiction and eventually my original stories are published here.



Zozma

Trash Mammal

Patron

36Years Young
38 Posts

Oh nice! Thank you!

 

(And noooo! It seems like things have to break before they work, doesn't it?!)


user posted image