Help - Search - Members - Calendar
Full Version: How to generate an MT template in PHP?
Movable Type Community Forum > Additional Resources > Tips and Tricks
otravers
Hi, I'm new to PHP and MT (I'm used tp vbscript/asp and Blogger Pro), so I'm sorry if my question is stupid, but even after reading MT's documentation and this forum I'm stuck.

I have created an index template in MT. In it I'm trying to mix MT tags and PHP code. When I alternate one with the other, everything's fine, but when I'm trying to use PHP variables as parameters within MT tags, that doesn't work. Here's an example:
CODE
<MTEntries sort_order="descend" days="<?=$DayCount?>">

($DayCount has been defined beforehand.) What's processed first, PHP or MT tags? It's a php page so I assume PHP has the priority here.

Alternatively I tried to generate HTML code with MT tags included through echo or print but that didn'twork either. I tried to escape quotes (\") but that didn't help.

Thanks a lot to anyone who can explain what's wrong with me. I can't figure it out.
kadyellebee
MT tags are generated first, and the the PHP is generated on the server afterwards. So your MTEntries tag needs to output the posts and then you can use php to show things afterwards.

Kristine
otravers
Thanks for your help, I see I got it backwards. At first glance this restricts how MT can be used programmatically, at least it can't be done the way I wanted to. I should probably tap the underlying MySQL database instead, or use the API.

Is there a mapping between MT Tags and database fields somewhere? Didn't see that in the manual.
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.