This allows you to add an additional field associated with a phpld link. This can be used, for instance, to add a field called “PHONE” when the submitters input his phone number. This was used in the deeplinks mod.

1. ADD the additional field (FIELD1) to the database:
The easiest way to do this is by running the sql query below in phpmyadmin

ALTER TABLE `PLD_LINK` ADD `FIELD1` TEXT NULL ;

2. The second step is to modify the submit form to add an input field with the same name “FIELD1″:

<tr>
  <td class="label">FIELD 1</td>
  <td class="field"><input type="text" name="FIELD1"
  value="{$FIELD1|escape|trim}"
 size="40" maxlength="255" class="text"/></td>
</tr>

Now the additional field is available in the database and can be filled from the submit form. Until now, the additional field is not visible from the admin panel. To make it accessible to the admin so it can be viewed or edited you will have to modify the following:

First, in admin/dir_approve_links.php

$columns = array ('TITLE' => _L('Title'),
'URL' => _L('URL'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

Replace by:

$columns = array ('TITLE' => _L('Title'),
'URL' => _L('URL'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'FIELD1' => _L('FIELD1'),
'DATE_ADDED' => _L('Date Added'));

Note that we have added the line 'FIELD1' => _L('FIELD1'),

Second, add the code below in templates/admin/link_details.tpl where you want the field to show

<tr class="{cycle values="odd,even"}">
<td class="label">FIELD 1:</td>
<td class="smallDesc">{$linkInfo.FIELD1|escape|trim}
</td>
</tr>

Finally, in templates/admin/dir_links_edit.tpl add the code below where you want to field to show when editing the listing in the admin panel.

<tr>
  <td class="label"><label for="FIELD1">
 FIELD 1:</label></td>
  <td class="smallDesc">
   <input type="text" id="FIELD1" name="FIELD1"
    value="{$FIELD1|escape|trim}" class="text" />           
  </td>
</tr>

Now the additional field can be viewed and edited from the admin panel. However it is not displayed yet to the directory visitor. Usually it will be displayed in the details page of each listing. This is done as follows:

1. in detail.php
Find:

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

Below it, add:

$data['FIELD1']    = $rdata['FIELD1'];

2. in detail.tpl, add the code below where you want the additional field to appear:

{$FIELD1|escape|trim}

If you are looking for the phpld seo friendly details pages mod click here.

With this small modification you can have seo friendly pages for the top links, latest links and latest articles. Actually this is already done in the .htaccess and all you have to do is to update your template to point to these pages. The file to modify is usually top-bar.tpl

FIND: {$smarty.const.DOC_ROOT}/index.php?list=latest
REPLACE BY: {$smarty.const.DOC_ROOT}/latest-links.html

FIND: {$smarty.const.DOC_ROOT}/index.php?list=latestarticles
REPLACE BY: {$smarty.const.DOC_ROOT}/latest-articles.html

FIND: {$smarty.const.DOC_ROOT}/index.php?list=top
REPLACE BY: {$smarty.const.DOC_ROOT}/top-hits.html

A demo here.

With this simple mod you can include any field from the link table in the URL of the details page. So instead of having a URL that looks like http://rakcha.com/phpld//link-18.html you can have it look like
http://www.rakcha.com/phpld/Paid_Web_Directories/enQuira-directory-25.html

Implementation:
in link.tpl
FIND:

{$smarty.const.DOC_ROOT}/detail/link-{$link.ID}.html

REPLACE BY (this is 1 line, there is no line break!):

{$smarty.const.DOC_ROOT}/{$link.CATEGORY_URL|escape|trim}
{$link.TITLE|escape|trim|replace:' ':'-'}-{$link.ID}.html

in detail.php
FIND:

preg_match ('#(.*)link(_|-)(\d+)\.htm[l]?$#i', request_uri(), $matches);

REPLACE BY:

preg_match ('#(.*)(_|-)(\d+)\.htm[l]?$#i', request_uri(), $matches);

The following line should be

$id = (!empty ($matches[3]) ? intval ($matches[3]) : 0);

So if you have $matches[1] replace it to $matches[3] for both instances.

in .htaccess
LOCATE the code between <IfModule mod_rewrite.c> and </IfModule>
REPLACE BY:

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

#Make sure RewriteBase points to the directory where you installed phpLD.
#Example: "/phpld" if your installation is in a "phpld" subdirectory.

RewriteBase /

##Latest Links Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^latest-listings\.htm[l]?$ index.php?list=latest [QSA,NC,L]

##Top Hits Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^popular-listings\.htm[l]?$ index.php?list=top [QSA,NC,L]

##Latest Articles Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^latest-articles\.html$ index.php?list=latestarticles [QSA,NC,L]

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


##Article Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)articles/article-(.*)\.htm[l]?$ article.php [QSA,NC,L]
   
##Details Link Page Rewrite   
RewriteRule %{REQUEST_URI} !page-[0-9]+\.html?$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)\.html$ detail.php [NC,QSA,L]


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

That’s it, you are done!

Extension: If you want to use any other field of the PLD_LINK Table, say you have a custom field for keywords named KEYWORDS, you can add {$link.KEYWORDS|escape|trim|replace:' ':'-'} to the URL.

PS: If you want to convert the added fields like $link.TITLE to lower case, you will have to add strtolower to it. The URL becomes:

{$smarty.const.DOC_ROOT}/{$link.CATEGORY_URL|escape|trim}
{$link.TITLE|escape|trim|strtolower|replace:' ':'-'}-{$link.ID}.html

PS2: To redirect old pages to your directory home, add the following in .htaccess

RewriteCond %{REQUEST_URI} ^(.*)/detail/link-(.*)\.html$
RewriteRule ^(.*)$ http://www.yourdirectory.com/ [R=301,L]

It is not possible to redirect old pages to new pages as the listing title or category are not available at the htaccess level. However this will not cause a problem as old pages will be promtply deindexed thanks to the 301 redirect to the homepage, and new pages indexed without causing duplicate content.
ENJOY!


© 2007 rakCha resources | Powered by Wordpress | rakCha web directory