Just wanted to let you know that I’m in the middle of a LIVE REDESIGN. Bear with me – the new version should be complete soon. In the mean time – Happy Thanksgiving!
focus on the clouds
  • CRW_4882
  • CRW_4764
  • CR2_4929
  • 126_2607
  • 135_3573

About Focus on the Clouds

Early in my life clouds began to catch my eyes. During school, I couldn’t sit by windows in class without being helplessly distracted. Later in life, if I needed to clear my mind, I’d just step outside...

Soon I began expressing this fascination artistically. In fact, this attraction has been one of the major muses for my photography and, as my domain suggests, this web site. And so it is also the purpose of the web site - to distract you for a few moments by sharing some of the scenes which have taken my attention in the past few years.

Latest Quote


$9.95/mo includes 20GB space, 1TB bandwidth, unlimited domains and SQL DBs. Sign up.

Subscribe by e-mail

Accessing Global Variables in Textpattern

Have you ever longed for the ability to display a bit of information stored in Textpattern, but you couldn’t find a way to access it? zem has greatly helped this issue, by sharing a very useful bit of code in the Textpattern Forums about accessing the url_title variable. In fact, this code helped solve a usability issue in my Photo Gallery that I couldn’t address otherwise (I’ll give you more details in a future post).

If you are running a recent build of RC3 (somewhere around of March 13, 2005) you should be able to use the Textpattern php tags to access this information (Note: Per zem, these tags may or may not make it into 1.0). For instance, the following code will display the url title for the current article:

<txp:php>echo $GLOBALS['thisarticle']['url_title'];</txp:php>

So, for this article the above code will display:

url_title: accessing-global-variables-in-textpattern

This becomes incredibly useful, because we can use this code to access any global variable by simply switching out the variables in the statement of code. I.E. if you wanted to display the last time your website was modified, you could enter:

<txp:php>echo $GLOBALS['prefs']['lastmod'];</txp:php>

And thanks to research shared by Henrik Jönsson in Global Variables in Textpattern. We now have a list of the variables which allow us to directly access this information through Textpattern pages, articles and forms!

Below I have listed a brief description, most known global variables and their corresponding Textpattern tags. Please help me flesh out any additional details or point out any inaccuracies in the comments.

Textpattern Global Variables
Description Global Variable Textpattern Tag
$prefs Site Preferences
Unknown ['prefs']['prefs_id']  
Site Name ['prefs']['sitename'] <txp:sitename />
Path from Root ['prefs']['path_from_root']  
Web Domain ['prefs']['siteurl']  
Site Tagline ['prefs']['site_slogan']  
Language ['prefs']['language']  
Timeoffset ['prefs']['timeoffset']  
Date Format ['prefs']['dateformat']  
Achive Dateformat ['prefs']['achive_dateformat']  
URL Mode ['prefs']['url_mode']  
Send Lastmodified Header ['prefs']['send_lastmod']  
Ping Weblogs.com ['prefs']['ping_weblogsdotcom']  
Logging ['prefs']['logging']  
Records Mentions ['prefs']['records_mentions']  
Use Textile ['prefs']['use_textile']  
Use Categories ['prefs']['use_categories']  
Use Sections ['prefs']['use_sections']  
Use Comments ['prefs']['use_comments']  
Comments Moderate ['prefs']['comments_moderate']  
Comments on Default ['prefs']['comments_on_default']  
Comments Default Invite ['prefs']['comments_default_invite']  
Comments Dateformat ['prefs']['comments_dateformat']  
Comments Mode ['prefs']['comments_mode']  
Comments Sendmail ['prefs']['comments_sendmail']  
Comments Disallow Images ['prefs']['comments_disallow_images']  
Comments Disabled After ['prefs']['comments_disabled_after']  
RSS How Many ['prefs']['rss_how_many']  
Date Site Last Modified ['prefs']['lastmod']  
Days Log Entries Exist ['prefs']['logs_expire']  
Directory to Images ['prefs']['img_dir']  
Textpattern Version ['prefs']['version']  
$pretext A Mix of Site & Article Data
Current Article ID ['pretext']['id'] <txp:id />
Current Section ['pretext']['s'] <txp:s />
Current Page ['pretext']['page'] <txp:page />
CSS ['pretext']['css'] <txp:css />
Current Category ['pretext']['c'] <txp:c />
Search Results ['pretext']['q'] <txp:q />
Unknown ['pretext']['count'] <txp:count />
Current Page ['pretext']['pg'] <txp:pg />
Unknown ['pretext']['p'] <txp:p />
Next ID ['pretext']['next_id'] <txp:next_id />
Next Title ['pretext']['next_title'] <txp:next_title />
Next URL Title ['pretext']['next_utitle'] <txp:next_utitle />
Previous Article ID ['pretext']['prev_id'] <txp:prev_id />
Previous Title ['pretext']['prev_title'] <txp:prev_title />
Previous URL Title ['pretext']['prev_utitle'] <txp:prev_utitle />
Path from Root ['pretext']['path_from_root'] <txp:path_from_root />
Subdirectory ['pretext']['pfr'] <txp:pfr />
URL mode ['pretext']['url_mode'] <txp:url_mode />
Site Name ['pretext']['sitename'] <txp:sitename />
$thisarticle Article Data
Current Article ID ['thisarticle']['thisid'] <txp:article_id />
Author ['thisarticle']['author'] <txp:author />
Posted Date ['thisarticle']['posted'] <txp:posted />
If comments? ['thisarticle']['if_comments']  
Comments Invite ['thisarticle']['comments-invite'] <txp:comments_invite />
Comments Count ['thisarticle']['comments_count'] <txp:comments_count />
Permanent Link ['thisarticle']['permlink'] <txp:permlink></txp:permlink>
Title ['thisarticle']['title'] <txp:title />
Article Excerpt ['thisarticle']['excerpt'] <txp:excerpt />
Body ['thisarticle']['body'] <txp:body />
Article URL Title ['thisarticle']['url_title']  
Category 1 ['thisarticle']['category1'] <txp:category1 />
Category 2 ['thisarticle']['category2'] <txp:category2 />
Article Section ['thisarticle']['section'] <txp:section />
Keywords ['thisarticle']['keywords'] <txp:meta_keywords />
Article Image ['thisarticle']['article_image'] <txp:article_image />
$thispage More Article Data
Current Pagenumber ['thispage']['pg']  
Total Pages of Articles ['thispage']['numPages']  
Current Section ['thispage']['s'] <txp:s />
Current Category ['thispage']['c'] <txp:c />

You can find zem’s Textpattern Forum post here.

You can find a more detailed list of global variables here.

Unfortunately, I’ve had to the close comments due to the number of spam items I’ve recieved. Please e-mail me at focusontheclouds@gmail.com if you have a question or would like to add a comment.

Posted by Matt Harris on Wednesday April 13, 2005

  1. # On Jul 25, 11:12 AM, Henrik said:

  2. # On Jul 25, 12:17 PM, Matt Harris said:

  3. # On Jan 30, 03:40 PM, Ashur said:

  4. # On Jul 19, 12:15 PM, Jonathan Clarke said:

  5. # On Jul 19, 01:57 PM, Matt Harris said:

  6. # On Jul 20, 09:22 AM, Jonathan Clarke said:

  7. # On Jul 20, 09:23 AM, Jonathan Clarke said:

  8. # On Oct 23, 11:10 PM, Nathan Smith said:

Subscribe by e-mail

This is a Flickr badge showing public photos from focus on the clouds. Make your own badge here.

Latest Photos

  • CRW_5561_RJ
  • CRW_5560_RJ
  • CRW_5557_RJ
  • CRW_5507_RJ
  • CRW_6475_RJ
  • CRW_6474_RJ

Photo Galleries

  • Nature
  • Clouds
  • Design
  • Memorials
  • Water
  • DC
  • 114_1492_RJ
  • 123_2375
  • 123_2378
  • 134_3414
  • CRW_6471_RJ

Home | Archive | Photography | My Diversions | About

© 2006 Matt Harris. All Rights Reserved.

  • Validate XHTML
  • Validate CSS
  • Great Hosting!