From 6da4bce8051666408ecc041d2b72f5c360bc4f72 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Fri, 13 Feb 2026 18:10:29 -0500 Subject: [PATCH] Ensure links from T&C index to Mostly Static Pages also include the base URL (CFM-501) --- .../Controller/TermsAndConditionsController.php | 17 +++++++++++++++++ app/templates/TermsAndConditions/columns.inc | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/Controller/TermsAndConditionsController.php b/app/src/Controller/TermsAndConditionsController.php index 8a47b76b9..b06349087 100644 --- a/app/src/Controller/TermsAndConditionsController.php +++ b/app/src/Controller/TermsAndConditionsController.php @@ -41,6 +41,23 @@ class TermsAndConditionsController extends StandardController { ] ]; + /** + * Callback run prior to the request render. + * + * @since COmanage Registry v5.1.0 + * @param EventInterface $event Cake Event + * @return \Cake\Http\Response HTTP Response + */ + + public function beforeRender(\Cake\Event\EventInterface $event) { + $this->set('vv_base_url', \Cake\Routing\Router::url( + url: "/" . $this->getCOID(), + full: true + )); + + return parent::beforeRender($event); + } + /** * Proxy an Agreement on behalf of a Person. * diff --git a/app/templates/TermsAndConditions/columns.inc b/app/templates/TermsAndConditions/columns.inc index 79dd0053b..620e141ba 100644 --- a/app/templates/TermsAndConditions/columns.inc +++ b/app/templates/TermsAndConditions/columns.inc @@ -49,13 +49,13 @@ $rowActions = [ [ 'icon' => 'arrow_outward', 'label' => __d('operation', 'visit.tandc'), - 'callbackUrl' => function($entity) { + 'callbackUrl' => function($entity) use ($vv_base_url) { // There should always be either a Mostly Static Page or a URL to reference. if(!empty($entity->mostly_static_page->name)) { // The T&C is a mostly static page. Provide a link to it. - return '/' . $entity->co_id . '/' . $entity->mostly_static_page->name; + return $vv_base_url . '/' . $entity->mostly_static_page->name; } return $entity->url; } ] -]; \ No newline at end of file +];