Jump to content

calling a variable from


npereira

Recommended Posts

hi,

 

i have a delima. I have a strip of code that I need to put in an include file called by every .php file in my site. My site uses smarty as a templating system.

 

The code is :

<?php
    if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
        if (!isset($phpAds_context)) $phpAds_context = array();
        $phpAds_raw = view_raw ('zone:37', 0, '', '', '0', $phpAds_context);
        $phpAds_raw1 = view_raw ('zone:31', 0, '', '', '0', $phpAds_context);
    }
    
    // Assign the $phpAds_raw['html'] variable to your template
//     echo $phpAds_raw['html'];
//     echo $phpAds_raw1['html'];
?>

 

When I put this code in a php file (ex: banner.php) I can see the banners. My problem relies on the fact that the whole site is templated and I need to call this function based on the zone on different locations of the templated files.

 

Example, the help.php page calls multiple include files including : include "./common.php"; at the top and has links to a template help_table.tpl which contains all the html and calls like {$data.content}

here is what the help_table.tpl looks like :

{include file="$gentemplates/index_top.tpl"}	
<td class="main_cell">
<!-- begin main cell -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="middle"><td height="25px" colspan=2>
		<div class="bg_header" style="width: 627px; margin: 0px; height: 25px;"><div style="padding: 5px 10px"><font class="my_menu">{$lang.section.help}</font></div></div>
</td></tr>
{if $form.err}
<tr><td height="25px" colspan=2 style="padding-left:15px;"><br><font class="error_msg">* {$form.err}</font> </td></tr>
{/if}
<tr><td colspan=2 style="padding:10px" class="profile_opt_value">
		{$data.content}
</td></tr>
<!-- BANNER TOP -->
	{if $banner.bottom}
	<tr><td height="10"></td></tr>
<tr>
<td colspan="2" valign="top" align="center">
	{$banner.bottom}
</td>
</tr>
{/if}
<!-- BANNER BOTTOM -->
</table>
<!-- end main cell -->
</td>
{include file="$gentemplates/index_bottom.tpl"}

 

The {$banner.bottom} is where I want to call the function with {$phpads.ZONE37}

The problem is I dont know where to start and what code to add where.

 

Can someone shed some light on this for me?

 

How do I format the code and put it in a file to be included in every page?

And how do I show the banners using a format like: {$phpads.ZONE37}

Link to comment
https://forums.phpfreaks.com/topic/37773-calling-a-variable-from/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.