XtGem get-variablesThese can be used on ANY XtGem site WITHOUT upgradingThis is a very complex subject so I will only cover the basics hereXtGem "get" variables can be used to replace any text or code in your site with a value that has been declared in a link or formIn your code or text a variable looks like this{_$variable_name|default_value}Original XtBoard post a simple form to display your name and ageThe Form<form id="myform" action="http://MY_SITE.COM#myform" method="get">This sets up the form and tells it where to go. (in this case back to itself) You can also use method="post" so that the variables will not appear in the url box<input type="text" name="myname" value="{_$myname|}" /> <input type="text" name="myage" value="{_$myage|}" />input the values for name and age The xt variables restores the last value of name and age after the form has been submitted<input type="submit" value="GO" /></form>Submit the form and close itThe output of the formyour name is Freddy Mercury your age is 26 your name is {_$myname|currently unknown } your age is {_$myage|also unknown}The Xt variables alter the text that is output Setting the values with a linkYou can set the values in the query string of a link my name is Freddy Mercury I am 26 You start the query string with a ? and use & to separate variables <a href="http://MY_SITE.COM?myname=Freddy Mercury&myage=26" >my name is Freddy Mercury I am 26</a>This link reloads the current page with the values for name and age set Passing values to another pageTo pass the currently set variables to another page on your site you must set the current values in the link to the new page a new page<a href="anotherpage?myname={_$myname|}&myage={_$myage|}">A new page</a>NOTE: the <xt:url /> and <xt:referer /> hidden Xt functions Will pass on any variables set in the url of a link or in forms using method="get"AUTOMATICALLYUsing in XT functions and widgets
This chatt box has it's custom key set by myname+myage from the form above or below
Use in Javascriptclick me <a href="javascript:alert('Hello {_$myname|stranger}');">click me</a><br />
Hiding things
You can use variables to hide or reveal parts of a page. there are 2 ways to do this Hiding in commentsHide and show using html comments. Anything between <!-- and --> is ignored by the browser. This places comments at the beginning and end of a section of code This is what the browser sees<!--span >Hiding in comments</span--><span >This will show on page load</span>This is the actual codeShow it now The code for the links What the browser sees <a href="http://tutorial.graham.yn.lt/Getvariables?hid=&hid2=!--">Show it now</a><!--a href="http://tutorial.graham.yn.lt/Getvariables?hid2=">hide it now</a-->This will show on page load
Hiding with csshide and show using css. this uses the css property "display:" to hide or reveal sections of code Show hidden and hide whats showingSwitch back again<div style="display:{_$hide2|block};border:4px outset #800;background:#f80;padding: 1em;width:72px;margin:0 auto;text-align:center">This shows on page load</div><div style="display:{_$hide|none};border:4px inset #080;background:#0f8;padding: 1em;width:72px;margin:0 auto;text-align:center">This was hidden</div>