Using Movable Type tags inside other Movable Type tags

| 1 Comment | No TrackBacks |

One of the most common problems people run into when they are getting started with advanced templating techniques in Movable Type is how to use the content of a tag as the input for another tag.

Often, they end up with something like this:

<mt:entries category="<mt:entrydatamyfield>"></mt:entries>

As they quickly discover, this won't work. Fortunately there is an easy way to make it.  You can use variables inside the attributes of other tags by preceding their names with a dollar sign ($).  So supposing you have a variable named 'stuff', you can do this:

<mt:entries category="$stuff"></mt:entries>

Great! That means if you could just get the value of your 'entrydatamyfield' tag into the 'stuff' variable, everything is hunky-dory!  There are even multiple ways of doing this. You could use a 'setvarblock' tag to capture the output of the 'entrydatamyfield' tag, for example:

<mt:setvarblock name="stuff"><mt:entrydatamyfield></mt:entrydatamyfield>


Or you could even use the tag directly and assign its output to the 'stuff' variable like this:

<mt:entrydatamyfield setvar="stuff">

Easy, isn't it?


No TrackBacks

TrackBack URL: https://www.movabletips.com/cgi-bin/mt/mt-tb.cgi/2

1 Comment

Hmm is anyone else encountering problems with the
images on this blog loading? I'm trying to figure out if its a problem
on my end or if it's the blog. Any suggestions would be greatly appreciated.

Leave a comment