We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25581
    • 16 Posts
    roulettered56 Reply #1, 18 years ago
    Where can I find a list of variables to use on my custom template for my MODx managed site?

    Also, am I right in thinking if I add a variable [*EXAMPLE*] to the source code of a template it will show the variable action on each page created with that template?

    Is that how they work?

    Thank you in advance for your help.

    Louis
      • 3749
      • 24,544 Posts
      http://modxcms.com/document-tvs.html

      The EXAMPLE TV will only appear on pages where you have [[*EXAMPLE*]] in the document content (assuming that they use the template with that TV). It will also appear if you have [[*EXAMPLE*]] in a chunk or produced by a snippet that’s called on that page.
        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
        • 25581
        • 16 Posts
        roulettered56 Reply #3, 18 years ago
        So I have to add a Variable on each page I create in the actual content? sad

        I was hoping by putting the Variable tag in the template code all new pages
        created using that template would show/do the function of the variable.

        Let’s say I want ALL pages created to use H1 tags for the headline, do I have
        to wrap each headline myself or is there a way (TV/ Chunk) to make the
        template default that function?

        I’ve converted to MODx but still I’m updated pages manually and individually lol.
          • 3749
          • 24,544 Posts
          You can use the longtitle of the page as the headline. Then, in your template, just put

          <h1>[*longtitle*]</h1>

          If you want the same content in many pages, just put the content in a chunk or in the template. Then, you edit it in one place and it changes in all the pages.

          Or, you can create your own custom Template Variable (TV) and put content in it.

          Or, if the content needs to be calculated, you can create a snippet that generates the content and it will appear on the page where you place the snippet call.
            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            BobRay, you’re spending too much time with Revolution! That should be
            <h1>[*longtitle*]</h1>
              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
              • 16183
              • 1,390 Posts
              Original quesion
              Where can I find a list of variables to use on my custom template for my MODx managed site?

              Also, am I right in thinking if I add a variable [*EXAMPLE*] to the source code of a template it will show the variable action on each page created with that template?

              Is that how they work?

              Thank you in advance for your help.

              Louis

              Quote from: BobRay at Oct 06, 2008, 07:21 PM

              http://modxcms.com/document-tvs.html

              The EXAMPLE TV will only appear on pages where you have [[*EXAMPLE*]] in the document content (assuming that they use the template with that TV). It will also appear if you have [[*EXAMPLE*]] in a chunk or produced by a snippet that’s called on that page.

              Is it just me or I think Louis’s first question was misunderstood? Reading this it seems it can be misunderstood that user created TVs’ placeholders (in this case [*EXAMPLE*] cannot be called in the templates source, i.e. within the html but only in the document content. Isn’t the correct position that TVs can either be called directly in the template or directly in the document? I might be the one misunderstanding the original question smiley
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                If he’s looking for a pre-defined list of available document variables, these are what he wants. They can be any field in the site_content table, although most of them would have little or no use for display on a page.

                Template Variables use the same syntax ([*TVName*]), but are user-generated. They are also tied to specific templates, while the above default document variables are not.
                  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
                  • 25581
                  • 16 Posts
                  roulettered56 Reply #8, 18 years ago
                  Thanks for the replies.

                  Alas I’m a bit lost. My goal was to have a CMS that creates pages on the fly based from a template that has my nav/ sign-up form/ header footer in which I specify a few things like URL and title etc and all that’s left is for me to add content/article to that page.

                  Let’s imagine I had a template:
                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml">
                  <head>
                  
                  <title>   title   |   description   </title>
                  
                  <!-- Javascript - Fix the flash of unstyled content -->
                  	<script type="text/javascript"></script>
                  
                  <!-- Stylesheets -->
                  	<link href="style/reset.css" rel="stylesheet" type="text/css" media="all" />
                  	<link href="style/default.css" rel="stylesheet" type="text/css" media="screen" />
                  	<link href="style/styling.css" rel="stylesheet" type="text/css" media="screen" />
                  	<!-- Print Stylesheet -->
                  	<link href="style/print.css" rel="stylesheet" type="text/css" media="print" />
                  
                  <!-- Meta Information -->
                  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
                  <meta http-equiv="imagetoolbar" content="no" />
                  <meta http-equiv="cache-control" content="public" />
                  <meta http-equiv="pragma" content="no-cache" />
                  <meta http-equiv="expires" content="never" />
                  <meta name="language" content="en-gb" />
                  <meta name="MSSmartTagsPreventParsing" content="true" />
                  <meta name="robots" content="index, follow" />
                  <meta name="revisit-after" content="14 days" />
                  <meta name="author" content="Mitchell Bryson" />
                  
                  <meta name="keywords" content="" />
                  <meta name="description" content="" />
                  
                  </head>
                  <body>
                  
                  	<div id="container">
                  
                  		<div id="header">
                  
                  			<div id="header-in">
                  
                  				header
                  
                  			</div> <!-- end #header-in -->
                  
                  		</div> <!-- end #header -->
                  
                  		<div id="content-wrap" class="clear rlcol">
                  
                  			<div class="column cleft">
                  
                  				<div class="column-in">
                  
                  					column one
                  
                  				</div> <!-- end .column-in -->
                  
                  			</div> <!-- end .column -->
                  
                  			<div class="column cright">
                  
                  				<div class="column-in">
                  
                  					column two
                  
                  				</div> <!-- end .column-in -->
                  
                  			</div> <!-- end .column -->
                  
                  			<div class="content">
                  
                  				<div class="content-in">
                  
                  					content
                  
                  				</div> <!-- end .content-in -->
                  
                  			</div> <!-- end .content -->
                  
                  		</div> <!-- end #content-wrap -->
                  
                  		<div class="clear"></div>
                  
                  		<div id="footer">
                  
                  			<div id="footer-in">
                  
                  				footer
                  
                  			</div> <!-- end #footer-in -->
                  
                  		</div> <!-- end #footer -->
                  
                  	</div> <!-- end div#container -->
                  </body>
                  </html>

                  By adding <title> [*pagetitle*] </title> to the template above, will each page created with that template have <title> My page title </title> ?

                  I got that TV from the Document Specific documentation.. is there a global Variable list?

                  Thanks
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Not sure what you mean. There are [*document-variables*] and [(site_variables)] available.

                    The document variables are taken from the site_content database. [*pagetitle*] and [*longtitle*] are the most commonly used, but it’s possible to use every field in that table. The ones mostly used correspond to the fields you fill out when you create/edit a document.

                    The site variables are taken from the system_settings table. They correspond to the fields you fill out when you use Tools -> Configuration, although a few also come from the manager/includes/config.inc.php file that is generated on installation. [(site_name)] and [(site_start)] are common ones; site_start returns the document ID you specify in the configuration as the document to use as the "home" or "index" document. Again, you can use any of these, although most of them wouldn’t have much use on a web page.

                    Maybe this will help: http://www.sottwell.com/how-templates-work.html

                      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
                      • 25581
                      • 16 Posts
                      roulettered56 Reply #10, 18 years ago
                      OK so.. By adding <title> [*pagetitle*] </title> to the template above, will each page created with that template have <title> My page title keywords </title> ?

                      My main reason for choosing MODx was so I didn’t have to edit each page separately. I thought by changing a chunk or variable on the template would affect each page using that template.

                      Thanks to everyone taking time out trying to help a noob.

                      I appreciate it.