We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14951
    • 151 Posts
    Anticipated Start Time
    As soon as possible

    Anticipated Job Duration
    Not sure on this one.. Short?

    Budget Constraints
    None, Just want to be mutually fair

    Payment Terms
    I’m flexible... 50% start / 50% complete?

    Scope of Work
    I’m looking to create a custom tv virtually identical to the functionality of Bruno17’s imagelist tv http://modxcms.com/forums/index.php/topic,52539.0.html. The only difference is that rather than an image upload field, I would like a group of (4) text input fields. Also identical to the imagelist tv, I will need a snippet that pulls in the data and allows me to template it. One little kicker in the snippet is that it will need to have a conditional that checks if the last text input field has data, and if so, use a different template. I’ll explain more in detail to whomever can help me with the project.

    IP ownership constraints (e.g., can the work be donated back to the community)
    This will definitely be given back to the community. Perhaps it is possible to simply do a fork off of the imagelist tv project?

    Thanks for your interest!
    -Jared
      • 4172
      • 5,888 Posts
      have send you a PM

      Bruno
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 4172
        • 5,888 Posts
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 17422
          • 225 Posts
          Hi Bruno,

          i use the multiItemsTv,
          just a little question,

          you it will be possible to add in the input options value. file or textfield or date etc..

          name:name:textfield||mp3:the mp3:file

          i’ll try to do this.

          Laurent
            • 17422
            • 225 Posts
            i found how to do this.

            but the value not save in the modx-panel-tv-file it’s not save.

            in multiitems.php :

            $option=explode(’:’,$option);
            $fieldnames[]=$option[0];
            $captions[]=!empty($option[1])?$option[1]:$option[0];
            $TypeChp[]=!empty($option[2])?$option[2]:"textfield";
            }

            and in the multiitems.tpl

            ,fields: Ext.util.JSON.decode(’{/literal}{$fieldnames}{literal}’)
            ,captions: Ext.util.JSON.decode(’{/literal}{$captions}{literal}’)
            ,TypeChp: Ext.util.JSON.decode(’{/literal}{$TypeChp}{literal}’)

            
            itemfield = {
                            xtype: this.TypeChp[i]
            
            


            I think we should add in the listeners :

            ,listeners: {
            ’change’: {fn:function(data) {
            this.fireEvent(’change’,data);
            this.collectItems();
            },
            ’select’: { fn:MODx.fireResourceFormChange
            }
            ,scope:this}


            but not work.

            i continue to work on this.
              • 17422
              • 225 Posts
              this is work fine

              the Template variable :
              name:nom de la chanson:textfield||mp3:fichier mp3:file


              with this code in multiitems.tpl


              <input id="tv{$tv->id}" name="tv{$tv->id}" type="hidden" class="textfield" value="{$tv->get('value')|escape}"{$style} tvtype="{$tv->type}" />
              <div id="tvpanel{$tv->id}">
              </div>
              <div id="tvpanel2{$tv->id}">
              </div>
              <br/>
              
              <script type="text/javascript">
                  // <![CDATA[
                  {literal}
                  MODx.panel.multiTvItem = function(config) {
                      config = config || {};
              		Ext.applyIf(config,{
                          layout: 'form'
                          ,autoHeight: true
                          ,border: false
                          ,style:{
                              'margin-bottom': '5px'
                              ,'border-bottom-width':'1px'
                          }
                          ,hideLabels: false
                          ,defaults: {
                              autoHeight: true
                              ,border: false
                          }
                          ,items: [{
              			    xtype: 'button'
                              ,text: 'delete item'
                              ,style:{
                                  'float': 'right'
                              }
                              ,listeners: {
                                  'click': {fn:function() {
              						var _thisitem = this;
              						var itemIdentifier = this.itemIdentifier;
                                      Ext.Msg.confirm(_('warning') || '','Remove Item?' || '',function(e) {
                                          if (e == 'yes') {
                                              console.log(config);
              								Ext.get(config.id).remove();
                                              config.tvpanel.collectItems();
                                          }
              	                    }),this;
                                  },scope:this}
                              }}
              				,{
              				xtype: 'fieldset'
              				,collapsible: false
                              //,collapsed: config.toggleCb=='on'?false:true
              				,collapsed: false
              				,checkboxToggle: true
              				,checkboxName: 'tv'+this.tvid+'_toggleCb_'+config.itemid
                              ,autoHeight: true
                              ,title: 'show Fields'
              				,items: config.itemfields
              				,width: '500px'
              			}]
                      });
                      MODx.panel.multiTvItem.superclass.constructor.call(this,config);
                      this.addEvents({select: true});
                  };
                  Ext.extend(MODx.panel.multiTvItem,MODx.Panel);
                  Ext.reg('modx-panel-multitvitem',MODx.panel.multiTvItem);
              
                  MODx.panel.multiItemsTV = function(config) {
                      config = config || {};
                      Ext.applyIf(config,{
                          autoHeight: true
                          ,border: false
                          ,style:{
                              'margin-bottom': '5px'
                              ,'border-bottom-width':'1px'
                          }
                          ,hideLabels: true
                          ,defaults: {
                              autoHeight: true
                              ,border: false
                          }
                          ,items: [{
                              xtype: 'button'
                              ,html: '<span>Add another item</span>'
              				,cls: 'ux-row-action-item ux-row-action-text'
                              ,listeners: {
                                  'click': {fn:function() {
                                      this.addItem({data:{}});
                                  },scope: this}
                              }
                          }]
                      });
              
                      MODx.panel.multiItemsTV.superclass.constructor.call(this,config);
              		this.loadInitItems();
                      this.addEvents({select: true});
                  }
                  Ext.extend(MODx.panel.multiItemsTV,MODx.Panel,{
              	itemIdentifier: 0
              	,tvid:'{/literal}{$tv->id}{literal}'
                  ,fields: Ext.util.JSON.decode('{/literal}{$fieldnames}{literal}')
              	,captions: Ext.util.JSON.decode('{/literal}{$captions}{literal}')
              	,TypeChp: Ext.util.JSON.decode('{/literal}{$TypeChp}{literal}')
              	,loadInitItems: function(){
                  var items_string = Ext.select("#tv"+this.tvid).elements[0].value;
                  var	items = [];
                  try {
                      items = Ext.util.JSON.decode(items_string);
                  }
                  catch (e){
              
                  }
              
                  if (items.length>0){
                      for (var i = 0; i < items.length; i++) {
                          //menueItem_Identifier++;
                          this.addItem({data:items[i]});
                      }
                  }
              	else {
              		//menueItem_Identifier++;
                      this.addItem({data:{}});
              	}
              	}
              	,addItem: function(config){
              
              		var data=config.data || null;
              
              		this.itemIdentifier++;
              		var itemfields=[];
                      for (i=0;i<this.fields.length;i++) {
                          if (this.TypeChp[i] =="file") {
                          itemfield = {
                              xtype: 'modx-combo-browser'
                              ,name: 'tv'+this.tvid+'_'+this.fields[i]+'_'+this.itemIdentifier
                              ,id: 'tv'+this.tvid+'_'+this.fields[i]+'_'+this.itemIdentifier
                              ,value: data[this.fields[i]]||''
                              ,width: '293px'
              				,fieldLabel: this.captions[i]
                              ,cls:'tv'+this.tvid+this.fields[i]
                              ,listeners: {
                                  'select': {fn: function(data) {
                                      this.fireEvent('select',data);
                                       this.collectItems();
                                  },scope:this}
                                  ,'change': {fn:function(D) {
                                  this.fireEvent('change',D);
                                   this.collectItems();
                                  },scope:this}
                              }
                           }
                          }
                          else {
                          itemfield = {
                              xtype: 'textfield'
                              ,name: 'tv'+this.tvid+'_'+this.fields[i]+'_'+this.itemIdentifier
                              ,id: 'tv'+this.tvid+'_'+this.fields[i]+'_'+this.itemIdentifier
                              ,value: data[this.fields[i]]||''
                              ,width: '293px'
              				,fieldLabel: this.captions[i]
                              ,cls:'tv'+this.tvid+this.fields[i]
                              ,listeners: {
                                  'change': {fn:function(D) {
                                  this.fireEvent('change',D);
                                   this.collectItems();
                                  },scope:this}
                              }
                           }
              
                          }
              
              			 itemfields.push(itemfield);
              		};
              		//console.log(items);
              
              
              		MODx.load({
              			xtype: 'modx-panel-multitvitem',
              			renderTo: 'tvpanel2' + this.tvid,
              			//fields:this.fields,
              			tv: this.tvid,
              			itemid: this.itemIdentifier,
              			//toggleCb:data['toggleCb']||'off',
              			cls: 'tv' + this.tvid + '_item',
              			id: 'tv' + this.tvid + '_item' + this.itemIdentifier,
              			width: '97%',
              			data: {description:''}
              			,itemfields : itemfields
              			,tvpanel:this
              		});
              	}
                  ,collectItems: function(){
                      var items=[];
                      var rows = Ext.select('.tv'+this.tvid+'_item');
                      //console.log(this);
              		var inputs = null;
              		var item = null;
              		var _this = this;
              		rows.each(function(row){
                          inputs = row.select('input');
              			//console.log(inputs);
              			item={};
              			inputs.each(function(input){
                          	var name = input.dom.name.substring(input.dom.name.indexOf("_")+1, input.dom.name.lastIndexOf("_"));
              				item[name]=input.getValue();
              				//console.log(name);
              			});
              			items.push(item);
                          //console.log(item);
                      });
              		//console.log(items);
                      Ext.select('#tv'+this.tvid).elements[0].value = Ext.util.JSON.encode(items);
                  }
              
              	});
                  Ext.reg('modx-panel-multiitemstv',MODx.panel.multiItemsTV);
              
                      MODx.load({
                          xtype: 'modx-panel-multiitemstv'
                          ,renderTo: 'tvpanel{/literal}{$tv->id}{literal}'
                          ,tv: '{/literal}{$tv->id}{literal}'
                          ,cls:'tv{/literal}{$tv->id}{literal}_items'
                          ,id:'tv{/literal}{$tv->id}{literal}_items'
                          ,width: '97%'
                      });
              
              
              </script>
              
              

                • 17422
                • 225 Posts
                Hi Bruno,

                I advance on my development but I’m stuck on a point.

                when i select the image with modx-combo-browser

                i want update a div with the data.relativeUrl but i don’t know how get the itemIdentifier in the select listeners (in red color).

                for (i=0;i<this.fields.length;i++) {
                if (this.TypeChp[i] =="file") {

                itemfield = [{
                xtype: ’modx-combo-browser’
                ,name: ’tv’+this.tvid+’_’+this.fields[i]+’_’+this.itemIdentifier
                ,id: ’tv’+this.tvid+’_’+this.fields[i]+’_’+this.itemIdentifier
                ,value: data[this.fields[i]]||’’
                ,width: ’493px’
                ,fieldLabel: this.captions[i]
                ,cls:’tv’+this.tvid+this.fields[i]
                ,listeners: {
                ’select’: {fn: function(data) {
                this.fireEvent(’select’,data);
                var d = Ext.get(’tv’+this.tvid+’preview_’+this.itemIdentifier);
                alert(config.tvid);
                this.collectItems();
                d.update(’<object type="application/x-shockwave-flash" data="/assets/components/dewplayer/swf/dewplayer-mini.swf" width="160" height="20" id="dewplayer1857710483" name="dewplayer1857710483" ><param name="wmode" value="transparent" /><param name="movie" value="/assets/components/dewplayer/swf/dewplayer-mini.swf" /><param name="flashvars" value="mp3=/’+data.relativeUrl+’&amp;autostart=0&amp;autoreplay=0&amp;showtime=0&amp;randomplay=0&amp;nopointer=0&amp;volume=100&amp;fading=0" /></object>’);
                },scope:this}
                ,’change’: {fn:function(D) {
                this.fireEvent(’change’,D);
                this.collectItems();
                },scope:this}
                }
                },{
                tag: ’div’
                ,id: ’tv’+this.tvid+’preview_’+this.itemIdentifier
                ,cls:’tv’+this.tvid+’preview’
                ,style:{
                ’float’: ’right’
                ,’height’: ’75px’
                ,’margin’: ’3px’
                ,’border’: ’1px solid’
                },
                html:’<object type="application/x-shockwave-flash" data="/assets/components/dewplayer/swf/dewplayer-mini.swf" width="160" height="20" id="dewplayer1857710483" name="dewplayer1857710483" ><param name="wmode" value="transparent" /><param name="movie" value="/assets/components/dewplayer/swf/dewplayer-mini.swf" /><param name="flashvars" value="mp3=/’+data[this.fields[i]]+’&amp;autostart=0&amp;autoreplay=0&amp;showtime=0&amp;randomplay=0&amp;nopointer=0&amp;volume=100&amp;fading=0" /></object>’
                }]
                }
                Thanks for your Help

                  • 17422
                  • 225 Posts
                  i found how to do this :

                  i update the code :

                  MODx.panel.multiItemsTV = function(config) {
                  config = config || {};
                  Ext.applyIf(config,{
                  autoHeight: true
                  ,border: false
                  ,style:{
                  ’margin-bottom’: ’5px’
                  ,’border-bottom-width’:’1px’
                  }
                  ,hideLabels: true
                  ,defaults: {
                  autoHeight: true
                  ,border: false
                  }
                  ,items: [{
                  xtype: ’button’
                  ,html: ’<span>Add another item</span>’
                  ,cls: ’ux-row-action-item ux-row-action-text’
                  ,listeners: {
                  ’click’: {fn:function() {
                  this.addItem({data:{},num:this.itemIdentifier});
                  },scope: this}
                  }
                  }]
                  });

                  MODx.panel.multiItemsTV.superclass.constructor.call(this,config);
                  this.loadInitItems();
                  this.addEvents({select: true});
                  }
                  Ext.extend(MODx.panel.multiItemsTV,MODx.Panel,{
                  itemIdentifier: 0
                  ,tvid:’{/literal}{$tv->id}{literal}’
                  ,fields: Ext.util.JSON.decode(’{/literal}{$fieldnames}{literal}’)
                  ,captions: Ext.util.JSON.decode(’{/literal}{$captions}{literal}’)
                  ,TypeChp: Ext.util.JSON.decode(’{/literal}{$TypeChp}{literal}’)
                  ,loadInitItems: function(){
                  var items_string = Ext.select("#tv"+this.tvid).elements[0].value;
                  var items = [];
                  try {
                  items = Ext.util.JSON.decode(items_string);
                  }
                  catch (e){

                  }

                  if (items.length>0){
                  for (var i = 0; i < items.length; i++) {
                  //menueItem_Identifier++;
                  this.addItem({data:items[i],num:i});
                  }
                  }
                  else {
                  //menueItem_Identifier++;
                  this.addItem({data:{},num:0});
                  }
                  }
                  ,addItem: function(config){
                  var data=config.data || null;
                  this.itemIdentifier++;
                  config.num++;
                  var itemfields=[];
                  for (i=0;i<this.fields.length;i++) {
                  if (this.TypeChp[i] =="file") {
                  itemfield = [{
                  xtype: ’modx-combo-browser’
                  ,name: ’tv’+this.tvid+’_’+this.fields[i]+’_’+this.itemIdentifier
                  ,id: ’tv’+this.tvid+’_’+this.fields[i]+’_’+this.itemIdentifier
                  ,value: data[this.fields[i]]||’’
                  ,width: ’493px’
                  ,fieldLabel: this.captions[i]
                  ,cls:’tv’+this.tvid+this.fields[i]
                  ,listeners: {
                  ’select’: {fn:function(data) {
                  this.fireEvent(’select’,data);
                  var d = Ext.get(’tv’+this.tvid+’preview_’+(config.num));
                  this.collectItems();
                  d.update(’<object type="application/x-shockwave-flash" data="/assets/components/dewplayer/swf/dewplayer-mini.swf" width="160" height="20" id="dewplayer1857710483" name="dewplayer1857710483" ><param name="wmode" value="transparent" /><param name="movie" value="/assets/components/dewplayer/swf/dewplayer-mini.swf" /><param name="flashvars" value="mp3=/’+data.relativeUrl+’&amp;autostart=1&amp;autoreplay=0&amp;showtime=0&amp;randomplay=0&amp;nopointer=0&amp;volume=100&amp;fading=0" /></object>’);
                  },scope:this}
                  ,’change’: {fn:function(D) {
                  this.fireEvent(’change’,D);
                  this.collectItems();
                  },scope:this}
                  }
                  },{
                  tag: ’div’
                  ,id: ’tv’+this.tvid+’preview_’+this.itemIdentifier
                  ,cls:’tv’+this.tvid+’preview’
                  ,style:{
                  ’float’: ’right’
                  ,’height’: ’75px’
                  ,’margin’: ’3px’
                  ,’border’: ’1px solid’
                  },
                  html:’<object type="application/x-shockwave-flash" data="/assets/components/dewplayer/swf/dewplayer-mini.swf" width="160" height="20" id="dewplayer1857710483" name="dewplayer1857710483" ><param name="wmode" value="transparent" /><param name="movie" value="/assets/components/dewplayer/swf/dewplayer-mini.swf" /><param name="flashvars" value="mp3=/’+data[this.fields[i]]+’&amp;autostart=0&amp;autoreplay=0&amp;showtime=0&amp;randomplay=0&amp;nopointer=0&amp;volume=100&amp;fading=0" /></object>’
                  }]
                  }
                  else {
                  itemfield = [{
                  xtype: ’textfield’
                  ,name: ’tv’+this.tvid+’_’+this.fields[i]+’_’+this.itemIdentifier
                  ,id: ’tv’+this.tvid+’_’+this.fields[i]+’_’+this.itemIdentifier
                  ,value: data[this.fields[i]]||’’
                  ,width: ’293px’
                  ,fieldLabel: this.captions[i]
                  ,cls:’tv’+this.tvid+this.fields[i]
                  ,listeners: {
                  ’change’: {fn:function(D) {
                  this.fireEvent(’change’,D);
                  this.collectItems();
                  },scope:this}
                  }
                  }]

                  }

                  itemfields.push(itemfield);
                  };
                  //console.log(items);
                    • 27985
                    • 54 Posts
                    Hey lolotlm (or anyone else who has or can get this working)

                    Can you post your working modified multiItems code in a code block, I can’t get what you pasted working and I suspect it’s at least in part due to the board formatting..

                    Thx!


                      MODx 2.0.6
                      PHP 5.3.3
                      MySQL 5.1.50
                      • 17422
                      • 225 Posts
                      and that’s all changed files.

                      in multiitems.php a update with $TypeChp




                      Laurent