Current location: Hot Scripts Forums » Programming Languages » PHP » Executing PHP in template?


Executing PHP in template?

Reply
  #1 (permalink)  
Old 03-03-09, 08:10 PM
scriptnoober91 scriptnoober91 is offline
New Member
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Executing PHP in template?

hi, my first post here... very nice site

im very new to scripting and web design so I have a few questions if anybody could spare a few mins

I am trying to set up a link submitter ( eSyndicat ) and also a news publisher (cutenews) on the same index page

I am using a template for the index page that contains the link submitter code.. the main index.php file points to .tlp files (template i assume) to display certain parts of the page

now my question is can I somehow execute PHP inside of this tlp script, because I have worked out how to edit the index.tlp file in order to add in another box section and im trying to get the news script to execute inside of it... there is enough room im sure

I managed to execute the php code inside of the main index.php file but it goes to very bottom of webpage as I cant add in these template boxes through the php file, only the tlp file if you know what I mean


The code in the main index.php file pointing to the .tlp files is like this:

$neighbour_categories = $Category->getNeighbours($id, $category['num_neighbours']);
$neighbour_categories = $neighbour_categories ? $gDirLayout->print_categories($neighbour_categories) : '';
$gDirSmarty->assign_by_ref('neighbour_categories', $neighbour_categories);
}

/** number of listings for current category and subcategories **/
$gDirSmarty->assign('num_listings', $category['num_all_listings']);

/** number of subcategories for current category **/
$num_categories = $Category->getNumSubcategories($id);
$gDirSmarty->assign_by_ref('num_categories', $num_categories);


$gDirSmarty->display('index.tpl'); ( as u can see here im directing to the tpl file )


the code in the template file to make my box section is like this:


<div class="box" style="border: none;">{$category.description}</div>


{include file="box-header.tpl" caption=$lang.categories}

*** I want to execute the PHP script inside here somehow ***

{include file="box-footer.tpl"}


{include file="footer.tpl"}



I know this is post is kind of vague as im not too sure about this stuff and maybe this isnt even possible, but any help would be appreciated... thanks, as you can see below im trying to get this php code to execute inside that news section
Attached Images
File Type: jpg site.jpg (49.4 KB, 64 views)
Reply With Quote
  #2 (permalink)  
Old 03-03-09, 08:56 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Looks like Smarty ... (http://smarty.net)
Code:
{* php tags indicate embedded php, be sure to use the braces *}
{php}
/* Simple echo to see something happen */
echo 'PHP!';
/* Set up a template variable with a value from php */
global $php_variable;  // If necessary
$this->assign('template_variable',$php_variable);
/* End of the php code */
{/php}
{* Template code *}
{* Display variable assigned in php *}
{$template_variable}

Last edited by wirehopper; 03-03-09 at 08:59 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] it works on localhost but not on hosting account? myslowquietlife PHP 42 12-19-08 09:31 AM
How to Create a Quiz with Free Quiz Template in Adobe Flash WPeterson Flash & ActionScript 0 10-22-08 10:54 PM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
php with Apache in windows eDevil PHP 3 08-08-04 12:03 AM
Good template system [PL]Greg PHP 3 06-28-03 04:09 AM


All times are GMT -5. The time now is 08:29 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.