MonkeyCMS Forum

Go Back   MonkeyCMS Forum > MonkeyCMS > Content Discussion
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 02-08-2010, 04:55 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 450
Default add a template from within inline php

Is there any way to add a template from within some inline php?

I'm trying to use the following code to display a MonkeyCMS template if a particular image exists on the server:

PHP Code:
%% $filename 'usedstock/output/AA08NNU1.jpg'$template1 "(template|Index:UsedCarThumbnail01)"; if (file_exists($filename)) ** addToOutput ("\n"); addToOutput ($template1); addToOutput ("\n"); ** %% 
But it only outputs "(template|Index:UsedCarThumbnail01)" onto the page.
Reply With Quote
  #2  
Old 02-08-2010, 05:00 PM
Colin Colin is offline
Administrator
 
Join Date: Apr 2007
Posts: 1,593
Default

How does this look?

Code:
%% $filename = 'usedstock/output/AA08NNU1.jpg'; $template1 = "Index:UsedCarThumbnail01"; if (file_exists($filename)) ** addToOutput ("\n"); displayTemplate(getTemplate($template1)); addToOutput ("\n"); ** %% 
Reply With Quote
  #3  
Old 02-08-2010, 05:02 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 450
Default

Beauty! Thanks for the quick reply Colin!
Reply With Quote
  #4  
Old 02-08-2010, 05:03 PM
Colin Colin is offline
Administrator
 
Join Date: Apr 2007
Posts: 1,593
Default

If you were to have this in a loop then I'd look at moving the getTemplate function outside of the loop as it'll be a little more efficient to do that.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 07:09 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© Poisonous Monkey