We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45613
    • 45 Posts
    I am trying to create my own CMP, so I have used BobRay's MyComponent Example extra and the Doodles tutorial as examples.

    The problem that I am having is the column headers for the table. Using BobRay's Example code the widget/chunk.grid.js file defines the columns with
    , columns: [this.sm, {
                header: _('id')
                ,dataIndex: 'id'
                ,sortable: true
                ,width: 50
            }, {
                header: _('name')
                ,dataIndex: 'name'
                ,sortable: true
                ,width: 100
                                                                                                               }, {
               header: _('category'),
                dataIndex: 'category',
                sortable: true,
                width: 120
            }, {
                header: _('description')
                , dataIndex: 'description'
                , sortable: false
                , width: 300
            }]

    My question is how does the line "header: _('name')" translate to "Name" when displayed on the page? Notice the capital "N"? However, the _('name') function does not just capitalize the first letter. Because if I change it to _('junk') and leave the dataIndex: 'name' the header is blank?

    The lexicon file does not have translations for any of the field names, so where is this coming from?

    I have followed the same steps on my CMP (header description matches the name of the dataIndex), and the headers are all blank, so must be missing some file of something.

    It would seem like I could put any value in the header to describe the dataIndex, but I can't see how to do this.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If you don't have a custom lexicon defined, I believe that it will fall back on the main core lexicon. For example, see lines 53, 109, 220, and 263 of the core/lexicon/en/default.inc.php. You'll find your translations there.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 45613
        • 45 Posts
        Brilliant. that explains it. None my field names are in the core default.inc.php.

        For my initial testing, I was being lazy and not putting anything into my lexicon file. Guess I need to do things correctly. smiley

        Thanks for the help!
          • 3749
          • 24,544 Posts
          The example CMP is a little goofy with respect to lexicon strings. Most of the strings are already in the Core lexicon. If you need to change them, you'll need to create lexicon files and make sure they're loaded.

          FYI, you can also put lexicon strings directly into the DB in Lexicon Management.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting