We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30223
    • 1,010 Posts
    Can we see your page with ’single characters’ somewhere? I’d be interested to see the page source. Might give a clue to what’s going on.

      • 26903
      • 1,336 Posts
      This kind of thing :-

      B
      o
      b
      S
      m
      i
      t
      h

      is caused because you are returning a string to the datagrid widget, it must be a resource(i.e from MYSQL) or an array. It prints it like that because a string is just an array of characters,
      you need to return ’names = array( 1=> ’Bob Smith’, 2 => ’Fred Jones’)’ etc. not just ’Bob Smith’. Having said that this should work from a @SELECT binding without further ado, if you are using @EVAL here be sure to co-erce your return values into an array before returning.

        Use MODx, or the cat gets it!
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Mmm... I’ll try this again. I’m quite sure my MySQL is correct... I’m very comfortable with MySQL and I’ve tested the query in the MySQL command line... in any case, the whole page explodes with a huge MODx error if the SQL has an error.

        Anyone want to update that Wiki page I started? (please, oh, please...)
          • 20413
          • 2,877 Posts
          The above DEFAULT VALUE call: @SELECT alias, pagetitle FROM modx_site_content WHERE template = 11
          changed to my template:  @SELECT alias, pagetitle FROM modx_site_content WHERE template = 6
          and with this:
          Column Name: alias, pagetitle
          Field Names alias, pagetitle

          Works perfect. Sweet thing!!  smiley
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            Ok, this is driving me insane... sweet thing? No, this is more like what Borat would call "a pain in my assholes". Can someone please point out how obliviously stupid I’m being? I’m getting the same old problem with a single letter in each row.

            Here’s what I got:

            ===My Template Variable====:
            Input Type: Text
            Input Option Values: --blank--
            Default Value:
            @SELECT pagetitle, alias FROM site_content WHERE parent=’129’
            Widget: Data Grid

            Widget Properties:
            Column Names: pagetitle,alias
            Field Names: pagetitle,alias
            Column Widths: 50
            Column Alignments: left
            Column Colors: -- blank --
            Column Types: text
            [... blank ...]


            MODx version 0.9.6.2

            Why doesn’t this work? I have even pasted my SQL query into PHPMyAdmin and I get 9 rows of results. I’ve cleared MODx’s cache and my browser cache... I’ve cut off the WHERE statement from my query and I’ve renamed my column names (so I know the page is refreshing), and I still get the same stuff: one letter per row.


              • 30223
              • 1,010 Posts
              PM me some login details and I’ll have a look for you when I get back from work tonight.
                • 30223
                • 1,010 Posts
                So I have had a look at Everettg_99’s server and I can now see where it’s going wrong.

                The default @SELECT works as long as no value is entered into the TV when editing the document.

                Here’s where the problem occurs. When you assign a value to the TV the value is stored in the database as a string exactly like it is (or as a comma delimited or a string with values delimited by || in case of multiple values), so when the datagrid widget receives this value it will treat it as an array of single characters.

                The datagrid expects either a valid sql resource or a proper array. Setting a value for the TV will normally only return a string, except in some cases when using @ Bindings. @SELECT for instance, or a properly constructed @EVAL. The latter you can try by filling in this into your TV
                @EVAL return array( array(’1’,’One’), array(’2’,’Two’), array(’3’,’Three’) );

                If your aim is to just use the default value (the @SELECT) than you just need to make sure to leave the TV empty in the document. I’ve used it like this on occasion as a convenient way of displaying DB data, however I hacked the Template Vars manager files to have an extra input type that simply hides the TV from the documents so that no one can accidentally enter values. The same can be achieved with the ManagerManager plugin.

                  • 20413
                  • 2,877 Posts
                  @Everettg_99 Booyakasha!!! cool Sorry! tongue
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 7231
                    • 4,205 Posts
                    however I hacked the Template Vars manager files to have an extra input type that simply hides the TV from the documents so that no one can accidentally enter values.
                    I think that you could do this with ManagerManager.
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don't know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 30223
                      • 1,010 Posts
                      Quote from: dev_cw at Nov 19, 2008, 04:43 AM

                      however I hacked the Template Vars manager files to have an extra input type that simply hides the TV from the documents so that no one can accidentally enter values.
                      I think that you could do this with ManagerManager.

                      Yes,.. I already said that smiley
                      ... The same can be achieved with the ManagerManager plugin.
                      However using 3 lines of php code -instead of many lines in a plugin that produces more lines of code- appeals to me for some reason. I’d love to see a ’hidden’ input type for TV’s in the core but am happy to make it a hack in my case.