From f86bc6f7152d1689c099666750be1798bd4dbf50 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 15 Sep 2009 04:11:13 +0000 Subject: [PATCH] ENHANCEMENT Added TableListField->paginationBaseLink git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@86338 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TableListField.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/forms/TableListField.php b/forms/TableListField.php index ba84707c1..6b97c9124 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -181,6 +181,13 @@ class TableListField extends FormField { */ protected $showPagination = false; + /** + * @var string Override the {@link Link()} method + * for all pagination. Useful to force rendering of the field + * in a different context. + */ + public $paginationBaseLink = null; + /** * @var int Number of items to show on a single page (needed for pagination) */ @@ -757,7 +764,8 @@ JS if(!isset($_REQUEST['ctf'][$this->Name()]['start']) || !is_numeric($_REQUEST['ctf'][$this->Name()]['start']) || $_REQUEST['ctf'][$this->Name()]['start'] == 0) { return null; } - $link = Controller::join_links($this->Link(), "?ctf[{$this->Name()}][start]={$start}"); + $baseLink = ($this->paginationBaseLink) ? $this->paginationBaseLink : $this->Link(); + $link = Controller::join_links($baseLink, "?ctf[{$this->Name()}][start]={$start}"); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); return $link; } @@ -771,7 +779,8 @@ JS $start = ($_REQUEST['ctf'][$this->Name()]['start'] - $this->pageSize < 0) ? 0 : $_REQUEST['ctf'][$this->Name()]['start'] - $this->pageSize; - $link = Controller::join_links($this->Link(), "?ctf[{$this->Name()}][start]={$start}"); + $baseLink = ($this->paginationBaseLink) ? $this->paginationBaseLink : $this->Link(); + $link = Controller::join_links($baseLink, "?ctf[{$this->Name()}][start]={$start}"); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); return $link; } @@ -783,7 +792,8 @@ JS if($currentStart >= $start-1) { return null; } - $link = Controller::join_links($this->Link(), "?ctf[{$this->Name()}][start]={$start}"); + $baseLink = ($this->paginationBaseLink) ? $this->paginationBaseLink : $this->Link(); + $link = Controller::join_links($baseLink, "?ctf[{$this->Name()}][start]={$start}"); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); return $link; } @@ -796,7 +806,8 @@ JS return null; } - $link = Controller::join_links($this->Link(), "?ctf[{$this->Name()}][start]={$start}"); + $baseLink = ($this->paginationBaseLink) ? $this->paginationBaseLink : $this->Link(); + $link = Controller::join_links($baseLink, "?ctf[{$this->Name()}][start]={$start}"); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); return $link; }