We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    Hi,

    I’m looking at the custom TV tutorial here but I have no idea why it works.

    I can understand the first file and parts of the second file but I’m stuck. Here are some questions
    ---
    xtype: ’modx-combo-template’
    What does it mean?
    Is this the part that loads the data from DB?
    Are there any other examples available/documentation because I have no?
    How can I change this to load information from a custom DB?
    ---
    listeners: { ’select’: { fn:MODx.fireResourceFormChange, scope:this}}
    After some test I manage to find that this line will make the SAVE button active. Are there any other things I should know?
    ---
    If I create a custom TV that has 2 dropdown lists what would be the appropriate code? Would something like this work

    <select id="tv{$tv->id}a" name="tv{$tv->id}a" class="combobox"></select>
    <select id="tv{$tv->id}b" name="tv{$tv->id}b" class="combobox"></select>
    ---
    The php file has this comment
    // any other PHP i want here

    What kind of php code would be added in there? Is this the place to load information from a custom table?


    Thank you
      • 28215
      • 4,149 Posts
      Quote from: cipa at Jun 06, 2010, 05:06 PM

      I’m looking at the custom TV tutorial here but I have no idea why it works.
      I can understand the first file and parts of the second file but I’m stuck. Here are some questions
      Yes, the documentation is very sparse. We’ll be working on that.


      xtype: ’modx-combo-template’
      What does it mean?
      Is this the part that loads the data from DB?
      Are there any other examples available/documentation because I have no?
      It means to use the ExtJS custom xtype ’modx-combo-template’, which loads a custom dropdown that shows a list of Templates.

      See:
      http://svn.modxcms.com/docs/display/revolution/MODExt
      http://svn.modxcms.com/docs/display/revolution/MODx.combo.ComboBox


      How can I change this to load information from a custom DB?
      You’ll have to define your own custom xtype, and add a ’getList’ processor that feeds the combobox back the records (similar to how the template one does it).

      See how I did it in Discuss that loads a custom ’category’ dropdown:

      The JS code: http://svn.modxcms.com/svn/modx-components/discuss/trunk/assets/components/discuss/js/mgr/combos.js
      The PHP code: http://svn.modxcms.com/svn/modx-components/discuss/trunk/core/components/discuss/processors/mgr/category/getlist.php

      Or, alternatively, you could load the data locally via a local combobox. ExtJS has documentation on how to do this on their site.


      After some test I manage to find that this line will make the SAVE button active. Are there any other things I should know?
      No that’s about it for TVs; there are other events that fire, but none should concern you when developing custom TVs.


      If I create a custom TV that has 2 dropdown lists what would be the appropriate code? Would something like this work
      <select id="tv{$tv->id}a" name="tv{$tv->id}a" class="combobox"></select>
      <select id="tv{$tv->id}b" name="tv{$tv->id}b" class="combobox"></select>
      No, you’ll need to somehow store the final value in a single hidden field; MODx will only process 1 of the fields - the one with tv{$tv->id}.


      The php file has this comment
      // any other PHP i want here
      What kind of php code would be added in there? Is this the place to load information from a custom table?
      Whatever you want, really. Anything that you might need to do in PHP to load your custom input type.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 5340
        • 1,624 Posts
        Thanks for the detailed reply. everything makes sense

        Probably I have to explain what I’m trying to achieve. I want to create a custom TV that will allow you to select the Country and second the State/Province.
        So basically I want that when you select a country in the first dropdown, I get all the States from the database and update the second dropdown with those values.

        Being a test TV it’s not important that I succeed but learn how it’s done. So any other information that might help me is welcomed.
          • 12682
          • 4 Posts

          No, you’ll need to somehow store the final value in a single hidden field; MODx will only process 1 of the fields - the one with tv{$tv->id}.

          Any chance you could elaborate on how to go about doing this? I’ve been stuck on it for a while. Should it just be javascript that concats the values and puts them in a field? I am using the URL tv input type as a reference and I don’t see any logic or place that it would both the prefix and the url... how do they do it on that TV type?