dedoo 0 Newbie Poster

Hi all,

I am wondering if anyone can help me with my problem.

I am in the process of starting a directory but I stumbled on a problem I would like to fix.

every link has an info link that redirects to an info page where more information can be found about that link.

The link is generated and I would like the "program" to generate a different link

the link I am getting now is http://www.fishingrolodex.com/fishing/link-14.html

where 14 is the ID of the link in my database

I however would like to change this to
http://www.fishingrolodex.com/fishing/<linktitle>-14.html

I tried to change this by changing link.ID into link.TITLE and however this works the link shows spaces and actually does not work at all lol

below I posted the codes of th pages I think are involved
Can somebode please look at this and try to help me out?
I would appreciate it very much

link.tpl (template file)

{strip}
<table><tr>
{* show page rank *}
{if $smarty.const.SHOW_PAGERANK}
   <td>
      {include file="pagerank.tpl" pr=$link.PAGERANK}
   </td>
{/if}

<td>
   <strong><a id="id_{$link.ID}" href="{$link.URL|escape|trim}" title="{$link.TITLE|escape|trim}"
   {* nofollow *}
   {if $link.NOFOLLOW or ($link.RECPR_VALID eq 0 and ($smarty.const.RECPR_NOFOLLOW eq 2 or 

($smarty.const.RECPR_NOFOLLOW eq 1 and $link.RECPR_REQUIRED eq 1)))} rel="nofollow"{/if}
   {if $smarty.const.ENABLE_BLANK} target="_blank"{/if}>
   {$link.TITLE|escape|trim}</a></strong> <span class="url">- {$link.URL|escape|trim}</span>
   <p>
      {$link.DESCRIPTION|escape|trim} -&nbsp;[<a href="{if !$smarty.const.ENABLE_REWRITE}
                                                {$smarty.const.DOC_ROOT}/detail.php?id={$link.ID}
                                             {else}
                                                {$smarty.const.DOC_ROOT}/fishing/link-{$link.ID}.html{/if}" title="{l}Read 

more about{/l}: {$link.TITLE|escape|trim}">{l}Info{/l}</a>

                                 {if $smarty.const.REQUIRE_REGISTERED_USER == 1 && !empty 

($regular_user_details) && ($regular_user_details.ID == $link.OWNER_ID)}
                                    ,&nbsp;<a href="{$smarty.const.DOC_ROOT}/submit.php?linkid={$link.ID}" 

title="{l}Edit or Remove your link{/l}">{l}Review{/l}</a>
                                 {/if}
                                 ]
   </p>
</td>
</tr>
</table>
{/strip}

and the details.php

require_once 'init.php';

if (ENABLE_REWRITE == 1)
{
   $dir = explode ("/", $_SERVER['REQUEST_URI']);
   $dir[sizeof ($dir)-1] = ereg_replace (".html$", "", $dir[sizeof ($dir)-1]);
   $dir[sizeof ($dir)-1] = ereg_replace ("^link-", "", $dir[sizeof ($dir)-1]);
   $id = $dir[sizeof ($dir)-1];
   }
else
   $id = (!empty ($_REQUEST['id']) ? $_REQUEST['id'] : 0);
   

if (!empty ($id))
{
   if (!preg_match ("/^\d+$/", $id))
      $tpl->assign('error', "Invalid Link ID");
   else
   {
      $rdata = $db->GetRow("SELECT *, DATE_FORMAT(DATE_ADDED, '%M %d, %Y %r') AS `DAT` FROM `{$tables['link']['name']}` WHERE `ID` = ".$db->qstr($id));
      $data = array ();
      if (!$rdata)
         $tpl->assign('error', "Invalid ID [{$id}] passed - not found in database");
      else
      {
         $data['ID']           = $id;
         $data['TITLE']        = $rdata['TITLE'];
         $data['DESCRIPTION']  = $rdata['DESCRIPTION'];
         $data['URL']          = $rdata['URL'];
         $data['CATEGORY_ID']  = $rdata['CATEGORY_ID'];
         $data['OWNER_NAME']   = $rdata['OWNER_NAME'];
         $data['DATE_ADDED']   = $rdata['DAT'];
         $data['HITS']         = $rdata['HITS'];
         $data['PAGERANK']     = $rdata['PAGERANK'];
         $data['RATE_COUNT']   = $rdata['RATE_COUNT'];
         $data['RATE']         = $rdata['RATE'];
         $data['RATE_ENABLED'] = $rdata['RATE_ENABLED'];
         $cdata                = $db->GetRow("SELECT `TITLE` AS `CATEGORY_TITLE`, `CACHE_TITLE`, `CACHE_URL` FROM `{$tables['category']['name']}` WHERE `ID` = '{$rdata['CATEGORY_ID']}' LIMIT 1");

         $data['CATEGORY_TITLE']  = $cdata['CATEGORY_TITLE'];
         $data['CACHE_TITLE']     = $cdata['CACHE_TITLE'];

         $site_url = (substr (SITE_URL, -1) != '/' ? SITE_URL.'/' : SITE_URL);
         $data['CATEGORY_URL']    = $site_url;
         $data['CATEGORY_URL']   .= (ENABLE_REWRITE == 1 ? trim ($cdata['CACHE_URL']) : 'index.php?c='.$data['CATEGORY_ID']);

         $data['META_KEYWORDS']    = $rdata['META_KEYWORDS'];
         $data['META_DESCRIPTION'] = $rdata['META_DESCRIPTION'];

         unset ($cdata, $site_url);
         $odata = $db->GetAll("SELECT * FROM `{$tables['link']['name']}` WHERE `OWNER_EMAIL` LIKE ".$db->qstr($rdata['OWNER_EMAIL'])." LIMIT 0 , 30");

         usort ($odata, "cmp");
         $data['RELATED'] = "";
         foreach ($odata as $value)
            if ($value['ID'] !== $id)
            {
               if (preg_match ("/\/$/", SITE_URL))
                  $link = SITE_URL."details.php?id=".$value['ID'];
               else
                  $link = SITE_URL."/details.php?id=" . $value['ID'];

               $data['RELATED'] .= "<li><a class=\"special\" href=\"{$link}\">{$value['TITLE']}</a></li>\n";
            }

         if($data['RELATED'])
            $data['RELATED'] = "<ul>\n{$data['RELATED']}</ul>\n";

         unset ($odata);
      }
   }
   unset ($rdata);
}
else
   $tpl->assign('error', "No ID parameter");

$path   = array ();
$path[] = array ('ID' => '0', 'TITLE' => _L(SITE_NAME)        , 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => SITE_DESC);
$path[] = array ('ID' => '0', 'TITLE' => _L('Listing Details'), 'TITLE_URL' => ''      , 'DESCRIPTION' => _L('Listing Details'));
$tpl->assign('path', $path);
$tpl->assign($data);

$tpl->assign('MetaKeywords'   , (!empty ($data['META_KEYWORDS'])    ? trim ($data['META_KEYWORDS'])    : trim ($MetaKeywords)));
$tpl->assign('MetaDescription', (!empty ($data['META_DESCRIPTION']) ? trim ($data['META_DESCRIPTION']) : trim ($MetaDescription)));

//Clean whitespace
$tpl->load_filter('output', 'trimwhitespace');

//Compress output for faster loading
if (COMPRESS_OUTPUT == 1)
   $tpl->load_filter('output', 'CompressOutput');

//Make output
echo $tpl->fetch('detail.tpl', $id);

unset ($data);

function cmp($a, $b) {
   return strcmp ($a["TITLE"], $b["TITLE"]);
}
?>

also the .htaccess file but I'm not sure if this is needed

# Protect files
<Files ~ "^(.*)\.(inc|inc\.php|tpl|sql)$">
  Order deny,allow
  Deny from all
</Files>

# Protect directories
<Files ~ "^(backup|files|images|include|lang|libs(/.+)?|temp(/.+)?|templates(/.+)?|javascripts(/.+)?)$">
  Order deny,allow
  Deny from all
</Files>

# Disable directory browsing
Options -Indexes

# Follow symbolic links in this directory
Options +FollowSymLinks

# Override PHP settings that cannot be changed at runtime
# (If your server supports PHP settings via htaccess you can comment following two lines off)
# php_value register_globals   0
# php_value session.auto_start 0

# Customized error messages
# ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" )
ErrorDocument 404 index.php?httpstatus=404

# Set the default handler
DirectoryIndex index.php

# URL rewrite rules
<IfModule mod_rewrite.c>
   RewriteEngine On

   ## Details Link Page Rewrite##
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)fishing/link-(.*).html$ detail.php [QSA,NC]

   ## Pagination Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)page-(\d+)\.html$  $1/?p=$2 [PT,NC]

   ## Category redirect
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>

Understand that I am no php expert or anything so thats why I am asking for help. I already posted my question on the forum where I downloaded the script for the directory but I'm getting no responses.

I would appreciate it very much if you could look into this.
please mail me @ dedoo (at) zonnet. nl if you need anything else

Kind regards,
Danny