We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10226
    • 412 Posts
    I have a TV, single select listbox that uses short names for ease in the coding, and to avoid spaces... What I would like is to associate that TV and the short-name with the proper non-shorthand name so I can display the proper name in the Ditto results, how is this done?

    example...

    Selecting IC results in the display of Integrated Circuit.

    Thanks!
      • 29181
      • 480 Posts
      Hey fruitwerks,
      not sure if I’m on the right track, but you mean setting the TV values like this?

      IC==Integrated Circuit ||LOL==Laugh out loud ||MODX==CMS and PHP Application Framework ||

      so selecting IC from the dropdown would give the TV a value of Integrated Circuit?

      Taff
        Adrian Lawley: www.adrianlawley.com
        • 10226
        • 412 Posts
        Well.. I guess? Is that all I need, just a ==?

        Thanks
          • 10226
          • 412 Posts
          ok I don’t see what the point of that is... I need short-names for scripting and proper names for display. I didn’t think it was that easy, because I have asked about something similar before.
            • 7231
            • 4,205 Posts
            This is not to complicated, all you need to do is setup a data source with the shortname = longname information and a snippet to look for the shortname and return the long name. The data source can be a database or a file or an array.

            How many names are there? If it is a large number I would use the data base. You can also populate the pulldown TV with the data from the database table.
              [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]
              • 10226
              • 412 Posts
              Currently there are about 7 items, and probably will not exceed 10, possibly 1 per year after that...

              When the user edits a document he/she will see a list showing Red, Green and Blue
              but when the data is save the values #FF0000, #00FF00 or #0000FF will be the
              actual value saved to the database.

              The user / client understands the shorthand names no prob, but the public does not, and it is the shorthand names that are displaying in the documents and it is the shorthand names I need to use while working the filters for Ditto. Am I crazy, or is this something else entirely?
                • 7231
                • 4,205 Posts
                Here is an example of a simple snippet based on a n array of data:
                <?php
                // [!ExtName? &v=`[*TV_with_short_name*]`!]
                
                //setup name array
                $name['IC'] = 'Integrated Circuit';
                $name['LOL'] = 'Laugh out loud';
                $name['MODX'] = 'CMS and PHP Application Framework';
                
                $output = isset($v) ? $name[$v] : "" ;
                
                return $output;
                
                ?>


                This sort of setup is commonly used for error messages or language files.
                  [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&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 10226
                  • 412 Posts
                  That is acceptable, but how do I call this? It is only on returned data from Ditto that I need this silent conversion, placing this globally would mess stuff up smiley

                  Thanks
                    • 7231
                    • 4,205 Posts
                    Quote from: fruitwerks at Jun 08, 2008, 10:01 AM

                    That is acceptable, but how do I call this? It is only on returned data from Ditto that I need this silent conversion, placing this globally would mess stuff up smiley

                    Thanks
                    Add it to the Ditto Tpl where you want the output to show:

                    [!ExtName? &v=`[+TV_with_short_name+]`!]
                      [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&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]