From b60994f1f2ae0bad1a5c62e41b282ab829e6fec8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 16 Mar 2016 11:27:49 +0000 Subject: [PATCH] use (mobile) template specific url on client-side to load sub-templates --- .../inc/class.etemplate_widget_template.inc.php | 16 +++++++++++++++- etemplate/js/et2_widget_template.js | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.etemplate_widget_template.inc.php b/etemplate/inc/class.etemplate_widget_template.inc.php index cb03c76f8e..51e4a5d3fa 100644 --- a/etemplate/inc/class.etemplate_widget_template.inc.php +++ b/etemplate/inc/class.etemplate_widget_template.inc.php @@ -7,7 +7,7 @@ * @subpackage api * @link http://www.egroupware.org * @author Ralf Becker - * @copyright 2002-11 by RalfBecker@outdoor-training.de + * @copyright 2002-16 by RalfBecker@outdoor-training.de * @version $Id$ */ @@ -249,6 +249,20 @@ class etemplate_widget_template extends etemplate_widget } $params[0] = $old_cname; } + + /** + * Fill type options in self::$request->sel_options to be used on the client + * + * @param string $cname + * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' + */ + public function beforeSendToClient($cname, array $expand=null) + { + //error_log(__METHOD__."('$cname') this->id=$this->id, this->type=$this->type, this->attrs=".array2string($this->attrs)); + $form_name = self::form_name($cname, $this->id, $expand); + + self::setElementAttribute($form_name, 'url', self::rel2url($this->rel_path)); + } } /* diff --git a/etemplate/js/et2_widget_template.js b/etemplate/js/et2_widget_template.js index 09ae454b4e..9ba519cb7d 100644 --- a/etemplate/js/et2_widget_template.js +++ b/etemplate/js/et2_widget_template.js @@ -83,6 +83,14 @@ var et2_template = (function(){ "use strict"; return et2_DOMWidget.extend( // Deferred object so we can load via AJAX this.loading = jQuery.Deferred(); + // run transformAttributes now, to get server-side modifications (url!) + if (_attrs.template) + { + this.id = _attrs.template; + this.transformAttributes(_attrs); + this.options = et2_cloneObject(_attrs); + _attrs = {}; + } if (this.id != "" || this.options.template) { var parts = (this.options.template || this.id).split('?');