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 +];