Help - Search - Members - Calendar
Full Version: MTSetVar & MTGetVar
Movable Type Community Forum > Additional Resources > Tips and Tricks
bmk
That's a good question, I'm interested too!  

smile.gif
Brenna
girlie
I'm just curious if anyone has made use of these tags, and if so, to what effect?

I was reading through the documentation again and wondering about any neat concepts they could be used for.

smile.gif
patski
I came here hoping you two had thrown some light on using these tags!

I'm trying to think about how I can incorporate my photos into MT pages. I'm quite happy with the layout but I'm sure MT would allow some wizardry. At the moment I'm using static pages and a .js file per page to swap the images. Probably best to have a look to see what I'm talking about!

There's two layouts depending on whether the photos are landscape or portrait (hidden form input?). Anyway I was trying to work out if SetVar and GetVar would help in any way to streamline things. Thoughts?
kadyellebee
I did a quick search and see that one or both of these variables are at use in these threads:

I would bet that if I searched further back, I'd find more mentions, but I believe that a lot of the older hacks may be superceeded by plugins. smile.gif

Kristine
kadyellebee
Oh, and PHP is pretty good at determing width/height using getimagesize. You could use that with a mathematical comparison to see if width or height was taller. And then set your output in if/else tags.

That was basic, but its something to think about smile.gif
Kristine
patski
Thanks. No problem with basic smile.gif php is still a mystery to me...

I looked at those threads but I was wondering if setvar could be used to read the image filenames from a list somehow. Maybe the category archive could be modified?
distler
I use 'em all over the place. There are big chunks of template code in my blog which is almost (but not quite) the same in different places in my blog.

I abstract that code into a Template module, use MTSetVar before including the module and then use the Compare plugin and MTGetVar to do whatever conditional execution needs to be done in that location.

As one (simple) example, I have two different RSS 2.0 Feeds, one with the full post contents in a <content:encoded> field, and one with descriptions only.

The template for my RSS 2.0 Full Content feed is:

CODE
<MTSetVar name="content-field" value="true"><MTInclude module="RSS2feed">

For the other feed, replace "true" with "false".
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.