prev/next/preload links for any page with a paginator
This commit is contained in:
		
							parent
							
								
									c3088c57fe
								
							
						
					
					
						commit
						ad905248e8
					
				| @ -83,6 +83,14 @@ class BaseThemelet | ||||
|         } | ||||
|         $body = $this->build_paginator($page_number, $total_pages, $base, $query, $show_random); | ||||
|         $page->add_block(new Block(null, $body, "main", 90, "paginator")); | ||||
| 
 | ||||
|         if($page_number < $total_pages) { | ||||
|             $page->add_html_header("<link rel='prefetch' href='".make_link($base.'/'.($page_number+1), $query)."'>"); | ||||
|             $page->add_html_header("<link rel='next' href='".make_link($base.'/'.($page_number+1), $query)."'>"); | ||||
|         } | ||||
|         if($page_number > 1) { | ||||
|             $page->add_html_header("<link rel='previous' href='".make_link($base.'/'.($page_number-1), $query)."'>"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private function gen_page_link(string $base_url, ?string $query, int $page, string $name): string | ||||
|  | ||||
| @ -44,13 +44,6 @@ and of course start organising your images :-) | ||||
| 
 | ||||
|         if (count($images) > 0) { | ||||
|             $this->display_page_images($page, $images); | ||||
|             if ($this->page_number < $this->total_pages) { | ||||
|                 $next = $this->page_number + 1; | ||||
|                 $u_tags = url_escape(Tag::implode($this->search_terms)); | ||||
|                 $query = empty($u_tags) ? "" : '/'.$u_tags; | ||||
|                 $next = make_link('post/list'.$query.'/'.$next); | ||||
|                 $page->add_html_header("<link rel='prefetch' href='$next'>"); | ||||
|             } | ||||
|         } else { | ||||
|             $this->display_error(404, "No Images Found", "No images were found to match the search criteria"); | ||||
|         } | ||||
|  | ||||
| @ -25,6 +25,10 @@ class ViewImageTheme extends Themelet | ||||
|         $page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); | ||||
|         $page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 20)); | ||||
|         //$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
 | ||||
| 
 | ||||
|         $query = $this->get_query(); | ||||
|         $page->add_html_header("<link id='nextlink' rel='next' href='".make_link("post/next/{$image->id}", $query)."'>"); | ||||
|         $page->add_html_header("<link id='prevlink' rel='previous' href='".make_link("post/prev/{$image->id}", $query)."'>"); | ||||
|     } | ||||
| 
 | ||||
|     public function display_admin_block(Page $page, $parts) | ||||
| @ -34,15 +38,18 @@ class ViewImageTheme extends Themelet | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     protected function build_pin(Image $image) | ||||
|     { | ||||
|     protected function get_query() { | ||||
|         if (isset($_GET['search'])) { | ||||
|             $query = "search=".url_escape(Tag::caret($_GET['search'])); | ||||
|         } else { | ||||
|             $query = null; | ||||
|         } | ||||
|         return $query; | ||||
|     } | ||||
| 
 | ||||
|     protected function build_pin(Image $image) | ||||
|     { | ||||
|         $query = $this->get_query(); | ||||
|         $h_prev = "<a id='prevlink' href='".make_link("post/prev/{$image->id}", $query)."'>Prev</a>"; | ||||
|         $h_index = "<a href='".make_link()."'>Index</a>"; | ||||
|         $h_next = "<a id='nextlink' href='".make_link("post/next/{$image->id}", $query)."'>Next</a>"; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user