PHPLD, index page only

Discussion in 'HTML & Website Design' started by bschneider5, Jun 4, 2006.

  1. #1
    Not sure if this is the right forum for this (famous opening words!) but I'd like to customize my phpld site, and not sure what to add in the main.tpl file so that certain code will only execute while on the main page. As it is right now, edits made to this file will execute on the main page, as well as category pages, etc. Any help would be great! Here is the 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}
    {assign var="in_page_title" value=$category.TITLE}
    {assign var="description" value=$category.DESCRIPTION}
    {include file="header.tpl"}
    
    {include file="top_bar.tpl"}
    
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="175" align="center" valign="top">{include file="leftside.tpl"}</td>
        <td>{$description}
        <br>
        {* Calculate the number of categories per row *}
    {php}
    $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs'))/ CATS_PER_ROW));
    {/php}
    
    {* Display categories heading if not on homepage *}
    {if $category.ID gt 0 and count($categs) gt 0}<h3>{l}Categories{/l}</h3>{/if}
    
    {* Categories *}
    <table border="0" align="center" cellpadding="0" cellspacing="2"><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>{/if}
        <h2><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE}</a>{if $smarty.const.CATS_COUNT} <span class="count">({$cat.COUNT})</span>{/if}</h2>
        
        {* Display subcategories *}
        <p class="subcats">
        {if $cat.SUBCATS}
            {foreach from=$cat.SUBCATS item=scat name=scategs}
            <a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL}/{$scat.TITLE_URL}/{else}index.php?c={$scat.ID}{/if}">
            {$scat.TITLE}</a>, {/foreach} ...
        {/if}    </p>
        {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>
    {if $smarty.const.FTR_ENABLE==1 and count($feat_links) gt 0}
        <h3>{l}Featured Links{/l}</h3>
        {foreach from=$feat_links item=link name=links}
            {include file="link.tpl" link=$link}
        {/foreach}
    {/if}
    {* Links heading and sorting*}
    {if ($qu or $category.ID gt 0 or $p) and count($links) gt 0}
        <h3>{l}Links{/l} {if not $p}<span class="small" style="margin-left: 50px">{l}Sort by{/l}:
        {if $smarty.const.ENABLE_PAGERANK and $smarty.const.SHOW_PAGERANK}{if $sort eq 'P'}<span class="sort"> {l}PageRank{/l}</span>{else}<a href="?s=P{if not $smarty.const.ENABLE_REWRITE}&c={$category.ID}{/if}{if $qu}&q={$qu}{/if}"> {l}PageRank{/l}</a>{/if} |{/if}
        {if $sort eq 'H'} <span class="sort">{l}Hits{/l}</span>{else} <a href="?s=H{if not $smarty.const.ENABLE_REWRITE}&c={$category.ID}{/if}{if $qu}&q={$qu}{/if}">{l}Hits{/l}</a>{/if}
        {if $sort eq 'A'} | <span class="sort">{l}Alphabetical{/l}</span>{else} | <a href="?s=A{if not $smarty.const.ENABLE_REWRITE}&c={$category.ID}{/if}{if $qu}&q={$qu}{/if}">{l}Alphabetical{/l}</a>{/if}
        </span>{/if}</h3>
        <div id="links">
        {foreach from=$links item=link name=links}
            {include file="link.tpl" link=$link}
        {/foreach}    </div>
    {/if}
    
    {* Javascript for tracking link clicks *}
    <script>
        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></td>
        <td width="175" align="center" valign="top">{include file="rightside.tpl"}</td>
      </tr>
    </table>
    {include file="footer.tpl"}
    {/strip}
    Code (markup):

     
    bschneider5, Jun 4, 2006 IP
  2. ing

    ing Well-Known Member

    Messages:
    500
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Try this..

     
    {if $category.ID eq 0 and not $p and not $qu}
    [I]what u want on the home page only goes here[/I]
    {/if}
    
    Code (markup):
    That works for version 2 of phpld
    :)
     
    ing, Jun 4, 2006 IP
    bschneider5 likes this.
  3. bschneider5

    bschneider5 Active Member

    Messages:
    1,009
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    88
    #3
    Hey man, that seems to work, thanks! (here's some green)
     
    bschneider5, Jun 4, 2006 IP
  4. promotion

    promotion Banned

    Messages:
    101
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think you should ask to David Duval who is the creator of the script. He some times stay online in directory forum.
     
    promotion, Jun 4, 2006 IP
  5. amitpatel_3001

    amitpatel_3001 Results Follow Patience

    Messages:
    14,074
    Likes Received:
    1,178
    Best Answers:
    0
    Trophy Points:
    430
    #5
    amitpatel_3001, Jun 4, 2006 IP
    sachin410 likes this.