We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34017
    • 898 Posts
    Hello,

    I am learning MODx and have spent the past 3 days reading through the docs and forum. Great info anf a good start on documentation!

    My question: How can I convert a website from Joomla to MODx. Let’s use this site as an example: www.alcmtjuliet.com.

    For this site, I have completed:
    - Setting up the site and System configuration
    - Added all of the pages (I love the unlimited hierarchy!)
    - Created a new template

    What I don’t understand for templates:
    - How do I only allow certain chunks to be seen on certain pages?

    Example: In Joomla, if I only wanted a chunk to show on the frontpage, I would type this in the template
    <!-- Show chunk only if user is on the frontpage -->
    <?php if ($option == "com_frontpage") {
    Show Content here 
    } ?>
    <!-- End showing of the chunk on the frontpage -->
    


    I believe this would be a place for Template Variables but am not sure. Thanks for your help.

    Chuck

    Also, for this site, I would like the right side block (or chunk) to be hidden when the user is on the "Monthly Letter" pages (it’s not like this now). In Joomla, I would only publish the modules for certain pages, then I would create the following code in my template:
    <!-- Show the right side DIV only if something is published in it -->
    <?php if ( mosCountModules( 'rightside') ) { ?>
            <div class="rightside"><?php mosLoadModules('rightside'); ?></div>
    <!-- End showing of right side -->
    
      Chuck the Trukk
      ProWebscape.com :: Nashville-WebDesign.com
      - - - - - - - -
      What are TV's? Here's some info below.
      http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
      http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That’s what TVs are for. The content of the TV can be edited for each page, or for each section using the @INHERIT bindings. The easiest thing to do is to use the content you’ll want for most of your pages as the default when you create the TV, then only edit the pages where you want something different.

        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
        • 34017
        • 898 Posts
        Susan,

        Thanks for your reply. I guess I just can’t get my head around Template Variables. Is there any site that shows some examples of how TV’s are used? If there was any place I could see an example of how someone used TV’s in a real world, that would be great.

        Thanks,
        Chuck
          Chuck the Trukk
          ProWebscape.com :: Nashville-WebDesign.com
          - - - - - - - -
          What are TV's? Here's some info below.
          http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
          http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Just consider TVs to be the big brother of the [*content*] tag.

          In fact, all of the values relating to a specific document can be considered simple TVs, such as [*pagetitle*], [*longtitle*], [*id*] or [*parent*] (these are the values you will see if you look in the site_content table in the database). TVs are basically just custom variables that relate to a given document, and are available for use for all documents using a given template.

          When you edit a document, the main "document content" field can be anything you like; it can contain HTML tags, snippets, chunks, raw text. Then wherever you choose to put the [*content*] tag in your template, it will appear. The same with TVs. For example:

          (HTML header stuff here)
          <body>
          <div id="banner">
          [*BannerTV*]
          </div>
          <div id="content">
          [*content*]
          </div>
          <div id="sidebar">
          [*SidebarTV*]
          </div>
          <div id="footer">
          {{FooterChunk}}
          </div>
          </body>
          </html>
          


          Now every document that uses the templates that were given access to the BannerTV and SidebarTV will have form fields for these TVs, just as they do for the Document content. The difference will be that they can contain a default value to begin with, and are much more flexible than the original document-specific variables. You can specify what kind of input fields each document will have, and how the TV’s output will be formatted.

          I have created chunks for each block in a sidebar, then created a TV with a multiple select drop-down as the input, with its default values the names of the chunks. Then the document editor could select which chunks he wanted in the sidebar for the document he was editing. The TV will automatically add those chunks to the sidebar when that page is generated.

          Sometimes I just enter the HTML for the sidebar, exactly as if I were editing the template directly, as its default. Then I can edit it for each document as I please. The only caveat there is that while you can have chunks and snippets in the code just as you can for the document content field, you can run into problems if you use other TVs.

          Why did I use a chunk for the footer? because the footer is not likely to change from document to document, and I think a chunk is marginally less "expensive" to process than a TV; besides which I prefer not to clutter up my document editing panel with irrelevant TV editing blocks.

          For similar reasons, I don’t use TVs for php code if it’s not going to change from page to page. So for blocks of HTML or PHP code that will not vary, I use chunks and snippets. For anything that will vary from page to page, I use a TV.
            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
            • 34162
            • 1 Posts
            Thanks Susan for this clear, concise explanation.
            However, there is a difference between the examples that ProWebscape has given and the working of TVs: The examples included "logic" (if-statements) - how can such an "intelligent" behaviour be made available in TVs? (For example: "show itemA if itemB equals itemC, else show itemD" or displaying different contents for different users?
            As far as I understand it, TVs are merely extensions to the record-structure of the pages (user-defined fields) and have nothing to do with logic or conditions: their values must always be set manually when another value than the default is required. But there are values which are user-dependent or simply not known at the time of editing but depending on "live-conditions". How to deal with these in MODx??
            Can PHP-code be used in TVs?
              • 16610
              • 634 Posts
              @bindings are probably what you are looking for: http://modxcms.com/what-are-at-bindings.html
                Mikko Lammi, Owner at Maagit
                • 28373
                • 204 Posts
                Quote from: ppaul at Jun 25, 2006, 06:51 AM

                ... depending on "live-conditions". How to deal with these in MODx??

                Here’s a case study from one of our sites, (as you’d say - it uses conditional logic) in this example to load a different/custom left menu navigation list depending on the title of a page. It uses the "tvcnd" snippet courtesy of Mark Caplan 26-Feb-2006.

                1. We have advertisers and each have a page containing information they wish published about them and/or their business.

                2. Each advertiser (we’ll call our example advertiser ’Matilda’) has the ability to add custom URLs to the bottom half of the left navigation, including, banner advertisements that they might wish to sell or give to persons interested in advertising at their page.

                A. We installed Mark’s snippet "tvcnd"
                B. We created a custom back end admin panel so advertisers can modify links then applied to a custom left navigation chunk, in this example we call that chunk "Matildas-Menu".
                C. We created a copy of the main template, and called that "Custom-Profile"
                D. In "Custom-Profile", where the site left navigation chunk is located, we replaced the chunk with this snippet call [!tvcnd? &tv=`pagetitle` &cnd=`Matilda, 2` &rtn=`Matildas-Menu`!]
                E. In the advertisers page, we changed the ’use template’ to ’Custom-Profile’.

                Each time ’Matildas’ page is accessed, the snippet call determines which left navigation to use based on the page title. Therefore, in this example, Matilda’s custom left navigation items and advertisements are displayed, rather, than the site default menu items.

                Giving advertisers the custom left nav option is now a simple matter of changing the template a page uses to ’Custom-Profile’, creating a copy of the default left nav chunk, and adding an extra snippet call in the ’Custom-Profile’ template for the page description matching the left navigation chunk. So the template might end up looking something like:-

                [!tvcnd? &tv=`pagetitle` &cnd=`Matilda, 2` &rtn=`Matildas-Menu`!]
                [!tvcnd? &tv=`pagetitle` &cnd=`Martha, 2` &rtn=`Marthas-Menu`!]
                [!tvcnd? &tv=`pagetitle` &cnd=`Jack, 2` &rtn=`Jacks-Menu`!]

                While this is entry level, the snippet Mark created has some powerful and wide ranging applications for conditional actions based on ’just’ a pages description. We elected this method since we have a custom back end for access and administration of advertiser details, custom links is an enhancement of features available to advertisers which they themselves can maintain, and we can moderate, before it’s passed back to MODx.

                -SB
                  • 34162
                  • 1 Posts
                  Cool stuff!
                  Thanks! Gotta look at this tvcnd snippet....

                  (and, compared to the Joomla stuff, which contains plain php in the source, this is by far more save & elegant.)
                    • 32963
                    • 1,732 Posts
                    Quote from: ppaul at Jun 25, 2006, 06:51 AM

                    Thanks Susan for this clear, concise explanation.
                    However, there is a difference between the examples that ProWebscape has given and the working of TVs: The examples included "logic" (if-statements) - how can such an "intelligent" behaviour be made available in TVs? (For example: "show itemA if itemB equals itemC, else show itemD" or displaying different contents for different users?
                    As far as I understand it, TVs are merely extensions to the record-structure of the pages (user-defined fields) and have nothing to do with logic or conditions: their values must always be set manually when another value than the default is required. But there are values which are user-dependent or simply not known at the time of editing but depending on "live-conditions". How to deal with these in MODx??
                    Can PHP-code be used in TVs?

                    There’s a new "intelligent" parser (that’s exactly was I was going to call it but I then changed my mind) in the works that allows you to do exactly what you asking for and much more.

                    The Intelligent Parser is only the beginning! Trust me on this one!
                      xWisdom
                      www.xwisdomhtml.com
                      The fear of the Lord is the beginning of wisdom:
                      MODx Co-Founder - Create and do more with less.
                      • 34017
                      • 898 Posts
                      Thank all of you for your help.

                      Your explanations and case-studies helped out a lot. I am starting to get the Template Variables.

                      Thanks,
                      Chuck
                        Chuck the Trukk
                        ProWebscape.com :: Nashville-WebDesign.com
                        - - - - - - - -
                        What are TV's? Here's some info below.
                        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008