Categories
Webmaster

Harnessing The GET Variable on Xtgem to Create Dynamic Web Pages

If you are quite familiar with server side scripting like PHP you might know about GET function right? GET function will take the parameter passed in the URL via the GET method or visible parameters in URL. Xtgem also has a built in GET variable that can be easily used to take parameter value passed in the URL.

Syntax:

{_$GET|}

– The GET is the parameter in the URL you want to get.
– The | symbol can be used to set a default string behind it if no GET parameter found in the URL. Example: {_$GET|Not Found}, it will return “Not Found” as the result.
– Even if you intend to not set a default string, you still must include the The | symbol!

xtcode xtgem by weblogwap

The GET variable can also be used to set values in xtgem codes to create a dynamic outputs of the code.

Xtgem get variable can be used on every html page of your xtgem site. If you are using “building tools”, then it can be used on “Code” block. Or edit your page using “code editor” mode to freely use it anywhere in the document.

Example of two pages on my xtgem site:
http://www.gratrik.gq/android-game/view/?get=The_Tribez_APK_DATA
http://www.gratrik.gq/android-game/view/?get=Tiny_Troopers_2_Special_Ops_APK_OBB

Actually the two are using a same page, it is located on http://www.gratrik.gq/android-game/view. But it is passed a same parameter (“get=”) with different values in the URL (“The_Tribez_APK_DATA” and “Tiny_Troopers_2_Special_Ops_APK_OBB”).

Create a dynamic web pages on your xtgem site using GET variable

Make a dynamic title on your xtgem site

In this example we are using “title=” parameter in our site URL.

Edit your page in “code editor” mode. Then replace the content inside <title></title> tag with “{_$title|} | Mysite”.


<!DOCTYPE html>
<html>

... ...

<title>{_$title|} | Mysite</title>

... ...

If you visit your page:
http://mysite.xtgem.com/somewhere?title=My New Page, the title on “somewhere” page now will be “My New Page | Mysite”.
http://mysite.xtgem.com/somewhere?title=Welcome, the title on “somewhere” page now will be “Welcome | Mysite”.

Make a dynamic image

We can also use GET variable to call different images on our xtgem site.
Example you have a folder named “images” in your xtgem site root directory containing image files named “1.png”, “2.png”, and “3.png”. For this example, we will use “img” parameter in the URL.

<img src=”/images/{_$img|}.png” />

If you visit your page:
http://mysite.xtgem.com/somewhere?img=1, then your “somewhere” page will display the image located on http://mysite.xtgem.com/images/1.png.
http://mysite.xtgem.com/somewhere?img=3, then your “somewhere” page will display the image located on http://mysite.xtgem.com/images/3.png.

Dynamic include files

Like I said earlier, xtgem GET variable can also be used to set the values on xtgem codes. For this example, we will use xtgem include file code: <xt:include file=”” />

Example you have a folder named “article” in your xtgem site root directory contains text files named “mydog.txt”, “mycar.txt”, and “myhouse.txt”. In this example, we will use “read” parameter in the URL.

<xt:include file=”/article/{_$read|}.txt” />

If you visit your page:
http://mysite.xtgem.com/somewhere?read=mydog, now your “somewhere” page will load content inside the file located on http://mysite.xtgem.com/article/mydog.txt
http://mysite.xtgem.com/somewhere?read=mycar, now your “somewhere” page will load content inside the file located on http://mysite.xtgem.com/article/mycar.txt

By SiDar

Webmaster Assistant and Editor at Indotechboy.com.

SiDar enjoying himself listening J-pop genre music and playing games, especially old school games. Sometimes he also found watching anime and reading manga are interesting when his fellow author recommend him some good titles.

Leave a Reply

Your email address will not be published. Required fields are marked *