We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Quote from: thinkweb at May 13, 2008, 09:03 AM

    So how would one go about adding custom fields to edit page?

    Thumbnail Name: [ some_file_name.png ]

    Then that is saved in the database somewhere?
    That is what TVs are for. Custom fields added to the document editing page. In this case, you would create a TV with an input type of Image, and an output widget of Image. Then put the [*TVname*] tags wherever you want the image to appear.
      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
      • 29847
      • 13 Posts
      Awesome, is there any in depth reading on TV’s and adding a custom field to the manager?

      Still very confused and I apologize.
        • 29847
        • 13 Posts
          • 29847
          • 13 Posts
          Ok so say I wanted to make a portfolio page for a web design company where you can add "Project Name" "Project Image" "Project Description". Then loop through those 3 fields on one page and also give them their own pages, what would be the basic instruction for that?
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Make a folder/container document named Portfolio. Make individual project pages under that parent document. Use Ditto to display the listing with links to the individual pages. Each individual page would have an image TV for a thumbnail image which would be used in the Ditto template. The project name and description would be the individual document’s Title and Summary (introtext) fields, also used in the Ditto template. See http://ditto.modxcms.com for more about using Ditto. The Wiki also has some good articles on different ways of using Ditto.
              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
              • 29847
              • 13 Posts
              Very cool, thank you very much for your time sottwell while I tackle this learning curve smiley
                • 3749
                • 24,544 Posts
                Quote from: sottwell at May 09, 2008, 11:25 AM

                In a nutshell:

                Modules are for adding features to the Manager, such as a newsletter management feature.
                Plugins are for interrupting normal processing to add custom functions (whether to parsing a document to generate a web page, or processing a user login, or processing the saving of an edited document, among the many processes that can be interrupted). This avoids the usual necessity to hack the core code.

                Snippets are PHP code whose return values get inserted into the web page. Similar to putting <?php someFunction(); ?> in an HTML page.
                Chunks are HTML code or raw text that gets inserted into the web page. They can contain snippet and TV tags.
                TVs are sort of a blend of snippets and chunks that are related to specified templates and can be edited on a page-by-page basis. They are closely related to the default document variables such as [*pagetitle*] and [*content*], which are based on the database fields in the site_content table.

                Very nice. Shamelessly stolen for bobsguides.com. grin
                  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
                  • 2217
                  • 21 Posts
                  Hi,

                  interested in specific use of Modules. Plugins, Snippets etc...
                  Which is the best place to put php functions and variables to be used inside (-shared by-) snippets?

                  Let’s say, I’ve got two snippets whose php code calls a php user-defined function.
                  Is there a unit where I can define the function to be called by those snippets?
                  Til now, I put the functions in a php file, then include_once that file in each snippet. But I think that’s not elegant nor functional. The best would be an automatic inclusion by modX before running any snippet... but I don’t know how... something like a sort of plugin allowing every snippet to use those functions.

                  thx in advance
                    • 10449
                    • 956 Posts
                    Create a plugin (resources > manage resources > plugins) and make sure you tick the "OnParseDocument" system event (3rd tab). The code can be as little as include_once(’assets/snippets/loadSomeStuff.php’);

                      • 2217
                      • 21 Posts
                      Thanks.
                      Shall the variables be global to be shared by snippets? shall variables and functions be declared in any special way?

                      I tried putting
                      $aaaaa=1;

                      as the WHOLE code of the plugin - and check OnParseDocument.

                      Checking the value of $aaaaa inside a snippet I obtained NULL.

                      Where did I make the mistake?