Help - Search - Members - Calendar
Full Version: Dynamic Publishing & Php Codeblocks In Entries
Movable Type Community Forum > Additional Resources > Tips and Tricks
newcomer
I previously posted my question to "Entries and Archives" and Smarty forum. In "Entries and Archives" forum no one answer me and I thought maybe I have posted it in wrong place. Therefore, I create this topic here.

For example I want to print something by php in one of my entries body (or in extended entry):
CODE
<?php echo 'This is an example.'; ?>

When my weblog publishing setting is statically, the code works and print: "This is an example." But, when weblog publishing set to build dynamically it does not work and in page source the code shown among other html tags and content.
CODE

<div class="entry-content">
    <div class="entry-body">
        <?php echo 'This is an example.'; ?>
    </div>
</div>

Someone in Smarty forum told me that I try "{php}…{/php}" tag but, its result was like what I write above. I myself tried "{{php}}…{{/php}}" that effected like other one.

Now, does anyone know how can I write php codeblocks into my post that they behave as such as expected?

Thank you.
newcomer
Isn't here anyone who can resolve the problem that I already mentioned? If you think what I want to do is impossible, please tell me that I leave it aside. huh.gif

Thanks.
DaveVT5
QUOTE (newcomer @ Dec 19 2005, 09:50 AM)
Isn't here anyone who can resolve the problem that I already mentioned? If you think what I want to do is impossible, please tell me that I leave it aside.  huh.gif

Thanks.
*


Given the time lapse you probably already figured this out but the answer is no, it cannot be done. This is because when Smarty outputs the PHP to display the content or extended entry what it is really doing in PHP is this:

CODE
<?php echo smarty_function_MTEntryBody(array(), $this);?>


or

CODE
<?php echo smarty_function_MTEntryMore(array(), $this);?>


So to add any PHP in the body for example <?php echo "Hello World!"; ?> what you would be getting is <?php ?> tags inside of other PHP tags and that doesn't work.
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.