We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3264
    • 7 Posts
    I am confused a bit on Modx. I know it uses a template system, but I am wondering if I can add it to my existing site which was developed in PHP/MySQL. I do not want to post all my code into to ModX, but instead would prefer to define editable regions and add code blocks to my pages (sort of like CushyCMS). Can this be done easily with Modx? I typically build my own basic CMS for each site I work with, but am growing tired of recreating the wheel each time. CushyCMS is to basic for my needs on many sites, and I also do not like the fact that it cannot be installed on my server.

    Any help is greatly appreciated.

    Bryan
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      MODx is based on the premise of parsing a template and inserting the dynamic content in place of the various MODx tags. http://www.sottwell.com/how-modx-works.html

      You could emulate what you are talking about using snippets and plugins to load various files, but it would be twice the work and awkward to boot. Trust me, once you try it the MODx way you’ll be hooked.

      As far as "editable content blocks", that is what Template Variables (TVs) are for. Only more flexible. And the latest improvements to the Quick Manager front-end page editor makes it even better.
        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
        • 3264
        • 7 Posts
        Since I am primarily a designer with some PHP experience, what is the best way for me to start with Modx? Any great tutorials or books?
          • 19369
          • 1,098 Posts
            • 3264
            • 7 Posts
            Thank you. Once I get the site uploaded, how can I use the Quick Manager feature?
              • 3264
              • 7 Posts
              can I use modx without using templates? I really like to have free control of the designs.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                MODx templates do give you free control of the design. MODx templates are nothing more than the page HTML with whatever content you want changed from page to page loaded in via MODx tags. For example, for a dynamic menu you would replace your hard-coded menu structure with the Wayfinder snippet tags. It uses its own mini-templates to customize the output; by default it generates a simple nested unordered list.

                Here is an example of an HTML 5 template I’m currently using.
                <!DOCTYPE html>
                <html lang="en">
                <head>
                <meta charset=[(modx_charset)]">
                <title>[(site_name)] - [*longtitle*]</title>
                <meta name="keywords" content="">
                <meta name="description" content="">
                <base href="[(site_url)]"></base>
                <link rel="stylesheet" type="text/css" href="assets/templates/naturalbeauties/common.css">
                <script src="assets/js/modernizr-1.1.min.js"></script>
                </head>
                <body>
                <header>
                	<logo>
                		<h1><a href="[(site_url)]">[(site_name)]</a></h1>
                		<h2>[*longtitle*]</h2>
                                <menu id="language"><ul><li>Language menu here</li></ul></menu>
                	</logo>
                	<menu id="main">
                		[[Wayfinder? &startId=`0` &level=`1`]]
                	</menu>
                </header>
                [*Gallery*]
                <section id="content">
                        [*content*]
                	<aside id="sidebar">
                		[*Sidebar*]
                	</aside>
                </section> <!-- end content -->
                <footer>
                       [*Footer*]
                </footer>
                <!--
                Design by Free CSS Templates
                http://www.freecsstemplates.org
                Released for free under a Creative Commons Attribution 2.5 License
                Converted to HTML 5 by sottwell.com
                -->
                </body>
                </html>
                


                However, you can use no template ("blank") for a page, and the parser will use the page’s content area instead of a template. So you could (as I mentioned earlier) use snippets (php code) to include your external files. Actually, that’s how I do AJAX processing; I use a MODx document (resource) with the "blank" template, and nothing in its content except the snippet tags for the PHP code to process the AJAX request. That gives me the advantage of having all the MODx API features, including a database connection, available.
                  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
                  • 4475
                  • 3 Posts
                  Yes you can use MODx without the templates. You can use any open source CMS without using templates. Use the backend to write to the MySQL tables then write your custom scripts to retrieve the data. My suggestion is to examine the tables in MODx (phpMyAdmin works nice for that) and see if you like their structure. If so, you’re good to go.
                    • 3264
                    • 7 Posts
                    Do you have a basic code example Scott that you use to add to your own site that I can see? Just curious what the code snippet looks like that links to the Modx API. Do you use the Quick Manager feature?
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Yes, I use Quick Manager quite a bit. It allows you to easily add your own links to its menu, so I can create a page on the front-end for managing the various front-end features like Jot or PubKitBlog, so a user can be a Manager user but never even see the Manager. His Manager Login Startup is set to the ID of the resource linked to in the QuickManager menu, so that’s where he gets sent as soon as he logs in.

                      Here’s the snippet code I use for processing a drag-and-drop sorting feature for Notes (an extension to Jot that I use for simple creation of various list-type things like FAQ pages or restaurant menus)
                      <?php
                      // saveOrder
                      // AJAX processor for sorting Notes items
                      
                      if ($_POST) {
                          $ids = $_POST['ids'];
                          foreach ($ids as $order => $id) {
                              $modx->db->update("position = $order", $modx->getFullTableName("notes_content"), "id = $id");
                          }
                      }
                      ?>

                      The AJAX on the web page sends the data as a POST array. In this case, I’m not returning anything, as all I want to do is change the order of the items. The Notes snippet call uses a &sortby=`position:a` parameter (the addition of that field to the jot_content table is one of the extensions to the original Jot that I did for Notes). The resource containing this snippet uses the "blank" template, and only has [[saveOrder]] snippet tags as its content.
                        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