September 05, 2008, 07:26:18 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Add your links to our directory. Click here to add your links.
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Add your links to our directory. Click here to add your links.
Pages: [1]
  Print  
Author Topic:

Smarty -> PHP

 (Read 1977 times)
0 Members and 1 Guest are viewing this topic.
Nite
Jr. Member
**

Points: 0
Offline Offline

Posts: 55



WWW
« on: February 08, 2007, 22:26:02 »

I use a phplinkdirectory theme that uses smarty.

Smarty looks like this (header.tpl):
Code:
{* Calculate title from path *}
{capture name="title"}
   {if count($path) > 1} - {/if}
   {foreach from=$path item=category name=path}
      {if $smarty.foreach.path.iteration gt 2}
         >
      {/if}
      {if not $smarty.foreach.path.first}
         {$category.TITLE}
      {/if}
   {/foreach}
{/capture}
{strip}
{if $title_prefix}
   {assign var="in_page_title" value=$title_prefix|cat:$category.TITLE}
{else}
   {assign var="in_page_title" value=$category.TITLE}
{/if}
{assign var="description" value=$category.DESCRIPTION}

{include file="header.tpl"}
{include file="top_bar.tpl"}

{* Calculate the number of categories per row *}
   {php}
      $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / CATS_PER_ROW));
   {/php}
{if $cats_per_col > 15}
   {php}
      $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / (CATS_PER_ROW + 1)));
   {/php}
{/if}


{* Show category search results *}
{if $search_category}
   {$search_category}
{/if}

{if isset($have_search_results) and $have_search_results == 0}
  <br /><div class="link">
      <p>{l}Sorry, no records found that match your keyword(s){/l}: "{$search|escape|wordwrap:200:"\n":true}"</p>
      <p>{l}Suggestions{/l}:</p>
      <p>
         <ul>
            <li>{l}Make sure all words are spelled correctly{/l}.</li>
            <li>{l}Try different keywords{/l}.</li>
            <li>{l}Try more general keywords{/l}.</li>
         </ul>
      </p>
   </div><br />
{/if}


{* Categories *}
{if !empty($categs)}



{* Categories *}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
{foreach from=$categs item=cat name=categs}
   {if ($smarty.foreach.categs.iteration mod $cats_per_col eq 1 and $cats_per_col gt 1) or $smarty.foreach.categs.first}<td valign="top"{if $category.ID==0} {/if}>{/if}

{* Start Categories Modifications By Vegabond *}

{if $category.ID==0}
<div id="cat_caption">
<p><img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.caption.right.gif" /></p>
<h1><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE|escape}</a>{if $smarty.const.CATS_COUNT} <span class="count">({$cat.COUNT})</span>{/if}
</h1>
</div>


{* Display subcategories *}

{if !empty($cat.SUBCATS)}<div id="cat_body">
<p><img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.body.right.gif" /></p>
{foreach from=$cat.SUBCATS item=scat name=scategs}

<div class="subcat"><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{$scat.TITLE_URL|escape}/{else}index.php?c={$scat.ID}{/if}">{$scat.TITLE|escape}</a></div>
{/foreach}
</div>



<div id="cat_footer">
<p><img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.footer.right.gif" /></p>
<img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.footer.left.gif" />
</div>
{/if}

{else}
<div class="subcat"><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE|escape}</a>{if $smarty.const.CATS_COUNT} <font size="1">({$cat.COUNT})</font>{/if}</div>
{/if}



{* End Categories Modifications By Vegabond *}

{if ($smarty.foreach.categs.iteration mod $cats_per_col eq 0 and $cats_per_col gt 1) or $smarty.foreach.categs.last}</td>{/if}
{/foreach}
</tr></table><br />
{/if}
{if $category.ID==0}<br />{/if}




{if $smarty.const.FTR_ENABLE == 1 and !empty($feat_links)}
<div class="break"></div>

<div class="catcaption">{l}Featured Listing{/l}</div><div class="dot"></div>
   
       {foreach from=$feat_links item=link name=links}
       <div class="link">{include file="f.link.tpl" link=$link}</div>
       {/foreach}     
{/if}

{* Links heading and sorting*}
{if ($uid || $search || !empty($category.ID) || $list) && !empty($links)}
<div class="link">
<div id="cat_caption">
<p><img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.caption.right.gif" /></p>

   {if not $list}<p class="sort">{l}Sort by{/l}:
   {if $smarty.const.ENABLE_PAGERANK and $smarty.const.SHOW_PAGERANK}{if $sort eq 'P'} {l}PageRank{/l}{else} <a href="?s=P{if !empty($p)}&amp;p={$p}{/if}{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}"> {l}PageRank{/l}</a>{/if} |{/if}
   {if $sort eq 'H'} {l}Hits{/l}{else} <a href="?s=H{if !empty($p)}&amp;p={$p}{/if}{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}">{l}Hits{/l}</a>{/if}
   {if $sort eq 'A'} | {l}Alphabetical{/l}{else} | <a href="?s=A{if !empty($p)}&amp;p={$p}{/if}{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}">{l}Alphabetical{/l}</a>{/if}
   {/if}

<h1>{l}Regular Listing{/l}</h1>
</div>

<div id="cat_body">
<p><img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.body.right.gif" /></p>
{foreach from=$links item=link name=links}
{include file="link.tpl" link=$link}<div class="dot"></div>
{/foreach}
</div>
<div id="cat_footer">
<p><img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.footer.right.gif" /></p>
<img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/cat.footer.left.gif" />
</div>

{/if}




{if $category.ID==0 and count($categs) gt 0}<div class="dot"></div>{include file="ads.tpl"}{/if}


{* Javascript for tracking link clicks *}
{if $StopLinkHits eq 0}
   <script language="javascript" type="text/javascript">
   /* <![CDATA[ */
      var root = '{$smarty.const.DOC_ROOT}';
      {literal}
      var a = document.getElementsByTagName("a");
      for(i = 0; i< a.length; i++)
         if(a[i].id != '')
            a[i].onclick = count_link;
      function count_link() {
         i = new Image();
         i.src= root+'/cl.php?id='+this.id;
         return true;
      }
      {/literal}
   /* ]]> */
   </script>
{/if}

{include file="footer.tpl"}
{/strip}

Since the template of my webdirectory, Smfoogle, uses Smarty, I need to be able to display top header, and the left navigational menu.. Where the "categories" are displayed, I would like to call another .php file which uses another database for link advertising.

Any idea as to how I can do this?
Logged



TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #1 on: February 09, 2007, 00:02:32 »

Just insert the following code there where you need Smiley

Code:
{php}
include("file.php")
{/php}

Regards
Logged

Nite
Jr. Member
**

Points: 0
Offline Offline

Posts: 55



WWW
« Reply #2 on: February 09, 2007, 09:06:20 »

* Nite feels retarded.

Ok, I'll try it.
Logged

Nite
Jr. Member
**

Points: 0
Offline Offline

Posts: 55



WWW
« Reply #3 on: February 09, 2007, 09:20:05 »

It worked!

Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!