After installing the contextual deep links mod, we will now modify few admin template files to allow the preview/editing of contextual links from the admin panel.

Files to edit:
admin/dir_approve_links.php,
templates/Core/admin/link_details.tpl,
templates/Core/admin/dir_links_edit.tpl.

First in admin/dir_approve_links.php
FIND:

$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'), 'TITLE1' => _L('Title1'),
'URL1' => _L('URL1') , 'TITLE2' => _L('Title2'),
'URL2' => _L('URL2') , 'TITLE3' => _L('Title3'),
'URL3' => _L('URL3') ,
'DESCRIPTION1' => _L('DESCRIPTION1'),
'DESCRIPTION2' => _L('DESCRIPTION2') ,
'DESCRIPTION3' => _L('DESCRIPTION3'),
'DESCRIPTION4' => _L('DESCRIPTION4'),
'DESCRIPTION' => _L('Description'),
'CATEGORY' => _L('Category'),
'RECPR_URL' => _L('Recpr. Link URL'),
'PAGERANK' => _L('Pagerank'),
'DATE_ADDED' => _L('Date Added'));

Second, in templates/admin/link_details.tpl
FIND, around line 34:

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

BELOW it, ADD:

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

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

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

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

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

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

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

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

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

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

FINALLY in templates/admin/dir_links_edit.tpl
FIND, around line 74

$smarty.const.DESCRIPTION_MAX_LENGTH}
         </td>
      </tr>

BELOW it , ADD

<tr>
<td class="label"><label for="TITLE1">
Title1:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE1" name="TITLE1"
 value="{$TITLE1|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL1">
URL1:</label></td>
<td class="smallDesc">
<input type="text" id="URL1" name="URL1"
 value="{$URL1|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE2">
Title2:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE2" name="TITLE2"
 value="{$TITLE2|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL2">
URL2:</label></td>
<td class="smallDesc">
<input type="text" id="URL2" name="URL2"
 value="{$URL2|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="TITLE3">
Title3:</label></td>
<td class="smallDesc">
<input type="text" id="TITLE3" name="TITLE3"
 value="{$TITLE3|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="URL">
URL3:</label></td>
<td class="smallDesc">
<input type="text" id="URL3" name="URL3"
 value="{$URL3|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="DESCRIPTION1">
Description 1:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION1" name="DESCRIPTION1"
 value="{$DESCRIPTION1|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="DESCRIPTION2">
Description 2:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION2" name="DESCRIPTION2"
 value="{$DESCRIPTION2|escape|trim}" class="text"/>
</td>
</tr>
      
<tr>
<td class="label"><label for="DESCRIPTION3">
Description 3:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION3" name="DESCRIPTION3"
 value="{$DESCRIPTION3|escape|trim}" class="text" />           
</td>
</tr>
<tr>
<td class="label"><label for="DESCRIPTION4">
Description 4:</label></td>
<td class="smallDesc">
<input type="text" id="DESCRIPTION4" name="DESCRIPTION4"
 value="{$DESCRIPTION4|escape|trim}" class="text"/>
</td>
</tr>

You are done!
If you liked this MOD, and want to show your appreciation, you can link back to
rakCha : http://www.rakcha.com
or
enQuira : http://www.enquira.com

In this step, we will display the keyword rich description in the details page.

1. in detail.tpl
FIND: around line 36

<tr>
<td class="label">{l}Description{/l}:</td>
</tr>
<td class="smallDesc" align="left">{$DESCRIPTION|escape|trim}</td>

AFTER it, ADD

<tr>
<td  class="label"><strong>Additional Information:</strong></td>
<td class="smallDesc" align="left">
{if $DESCRIPTION1}{$DESCRIPTION1}&nbsp;
{/if}

{if  $TITLE1 && $TITLE1 neq 'http://'}
<a href="{$URL1}" target="_blank" class="title">{$TITLE1}</a>&nbsp; 
{/if}

{ if $DESCRIPTION2}
{$DESCRIPTION2}&nbsp;
{/if}

{if $TITLE2 && $TITLE2 neq 'http://'}
<a href="{$URL2}" target="_blank" class="title">{$TITLE2}</a>&nbsp;  
{/if}

{ if $DESCRIPTION3}
{$DESCRIPTION3}&nbsp;
{/if} 

{ if $TITLE3 && $TITLE3 neq 'http://'}
<a href="{$URL3}" target="_blank" class="title">{$TITLE3}</a>&nbsp;
{/if}

{ if $DESCRIPTION4}&nbsp;
{$DESCRIPTION4}.
{/if}  

</td>
</tr>

2. in /detail.php
FIND:

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

BELOW it, ADD:

$data['TITLE1']    = $rdata['TITLE1']; 
$data['URL1']    = $rdata['URL1']; 
$data['TITLE2']    = $rdata['TITLE2']; 
$data['URL2']    = $rdata['URL2']; 
$data['TITLE3']    = $rdata['TITLE3']; 
$data['URL3']    = $rdata['URL3']; 
$data['DESCRIPTION1']    = $rdata['DESCRIPTION1']; 
$data['DESCRIPTION2']    = $rdata['DESCRIPTION2']; 
$data['DESCRIPTION3']    = $rdata['DESCRIPTION3']; 
$data['DESCRIPTION4']    = $rdata['DESCRIPTION4'];

By Step 3, your directory is set to accept contextual deep links and display them in a keyword rich paragraph in the details page. The last step, we will modify the admin template files to allow preview/editing of the contextual deep links from the admin panel.

If you liked this MOD, and want to show your appreciation, you can link back to
rakCha : http://www.rakcha.com
or
enQuira : http://www.enquira.com

In this step we will modify the submit form to accept additional contextual links for featured listings.
1. create a contextual.js file in the javascript folder (under the directory root) with the following content:

function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
function setValue(id, value) {
document.getElementById(id).value = value;
}
function regular(){
setVisibility('contextuallinkspreview', 'none');
setVisibility('contextuallink1', 'none');
setVisibility('contextuallink2', 'none');
setVisibility('contextuallink3', 'none');
setVisibility('contextualtitle1', 'none');
setVisibility('contextualtitle2', 'none');
setVisibility('contextualtitle3', 'none');
setVisibility('contextualdescription1', 'none');
setVisibility('contextualdescription2', 'none');
setVisibility('contextualdescription3', 'none');
setVisibility('contextualdescription4', 'none');

setValue('URL1', '');
setValue('URL2', '');
setValue('URL3', '');
setValue('TITLE1', '');
setValue('TITLE2', '');
setValue('TITLE3', '');
setValue('DESCRIPTION1', '');
setValue('DESCRIPTION2', '');
setValue('DESCRIPTION3', '');
setValue('DESCRIPTION4', '');
setValue('contextual-description', '');
}
function featured(){
setVisibility('contextuallinkspreview', '');
setVisibility('contextuallink1', '');
setVisibility('contextuallink2', '');
setVisibility('contextuallink3', '');
setVisibility('contextualtitle1', '');
setVisibility('contextualtitle2', '');
setVisibility('contextualtitle3', '');
setVisibility('contextualdescription1', '');
setVisibility('contextualdescription2', '');
setVisibility('contextualdescription3', '');
setVisibility('contextualdescription4', '');
}
function reciprocal(){
setVisibility('contextuallinkspreview', 'none');
setVisibility('contextuallink1', 'none');
setVisibility('contextuallink2', 'none');
setVisibility('contextuallink3', 'none');
setVisibility('contextualtitle1', 'none');
setVisibility('contextualtitle2', 'none');
setVisibility('contextualtitle3', 'none');
setVisibility('contextualdescription1', 'none');
setVisibility('contextualdescription2', 'none');
setVisibility('contextualdescription3', 'none');
setVisibility('contextualdescription4', 'none');

setValue('URL1', 'none');
setValue('URL2', 'none');
setValue('URL3', 'none');
setValue('TITLE1', 'none');
setValue('TITLE2', 'none');
setValue('TITLE3', 'none');
setValue('DESCRIPTION1', 'none');
setValue('DESCRIPTION2', 'none');
setValue('DESCRIPTION3', 'none');
setValue('DESCRIPTION4', 'none');
setValue('contextual-description', '');
}


function $(id) {
    return document.getElementById(id) ;
}
function updatePreview() {
    var result = "";

	var part1 = "";
	if ($('DESCRIPTION1').value.length > 0) {
        part1 = $('DESCRIPTION1').value;
    }
	
    var part2 = "";
    if ($('TITLE1').value.length > 0) {
        part2 = " <a href=\"" + $('URL1').value +
       "\" target=\"_blank\">" + $('TITLE1').value + "</a> ";
    }
	
    var part3 = "";
   if ($('DESCRIPTION2').value.length > 0) {
        part3 = $('DESCRIPTION2').value;
    }	

    var part4 = "";
    if ($('TITLE2').value.length > 0) {
        part4 = " <a href=\"" + $('URL2').value +
       "\" target=\"_blank\">" + $('TITLE2').value + "</a> ";
    }

	var part5 = "";
	if ($('DESCRIPTION3').value.length > 0) {
        part5 = $('DESCRIPTION3').value;
    }

    var part6 = "";
    if ($('TITLE3').value.length > 0) {
        part6 = " <a href=\"" + $('URL3').value +
        "\" target=\"_blank\">" + $('TITLE3').value + "</a> ";
    }
	
   var part7 = "";
        if ($('DESCRIPTION4').value.length > 0) {
        part7 = $('DESCRIPTION4').value;
    }	
	
    part8 = "";
   if (part1.length > 0 || part2.length > 0 || 
       part3.length > 0 || part4.length > 0 || 
       part5.length > 0 || part6.length > 0 || 
       part7.length > 0) {
  	part8 = ".";
   }


   result =  part1 + part2 + part3 + part4 +
               part5 + part6 + part7 + part8;

    $('contextual-description').innerHTML = result;
}



function updateField(fieldName, onKeyUp) {
    var elem = $(fieldName) ;
    elem.onkeyup = onKeyUp ;
    elem.onclick = onKeyUp ;
}

function updateContextualPreview() {

    var triggerUpdate = 
          function()  { updatePreview();  } ;

    for(var i=1;i<4;i++) {
        updateField("URL"+i, triggerUpdate) ;
        updateField("TITLE"+i, triggerUpdate) ;
        updateField("DESCRIPTION"+i, triggerUpdate) ;
    }
    updateField("DESCRIPTION"+4, triggerUpdate) ;
}

2. right before in header.tpl, ADD

{* Contextual Deep Links *}
<script type="text/javascript" 
src="{$smarty.const.DOC_ROOT}/javascripts/contextual.js"></script>

3. in submit.tpl
FIND, around line 113:

{l}Limit{/l}: 
<input type="text" name="DESCRIPTION_limit" size="4" 
class="limit_field" readonly="readonly" value="{$DescriptionLimit|trim}" />
</td>
</tr>

AFTER it, ADD

<tr id="contextuallinkspreview"  style="display:none">
<td class="label">Preview<br></td>
<td class="field">
<div class="contextual_preview" style="width:300px;"><br />
<span id="contextual-description"></span><br /><br />
</div>
</td>
</tr>

<tr id="contextualdescription1"  style="display:none">
<td class="label"><strong>Description Part 1:</strong></td>
<td class="field">
<textarea id="DESCRIPTION1" name="DESCRIPTION1" cols="30" rows="2">
</textarea>
</td>
</tr>
				  
<tr id="contextualtitle1"  style="display:none">
<td class="label"><strong>Keyword 1:</strong></td>
<td class="field">
<input type="text" name="TITLE1" value="" size="30" id="TITLE1" />
</td>
</tr>						
									
<tr id="contextuallink1"  style="display:none">
<td class="label"><strong>URL 1:</strong></td>
<td class="field">
<input type="text" name="URL1" value="" size="30" id="URL1" />
</td>
</tr>						
	
<tr id="contextualdescription2"  style="display:none">
<td class="label"><strong>Description Part 2:</strong></td>
<td class="field">
<textarea id="DESCRIPTION2" name="DESCRIPTION2" cols="30" rows="2">
</textarea>
</td>
</tr>							
					
<tr id="contextualtitle2"  style="display:none">
<td class="label"><strong>Keyword 2:</strong></td>
<td class="field">
<input type="text" name="TITLE2" value="" size="30" id="TITLE2" />
</td>
</tr>						

<tr id="contextuallink2"  style="display:none">
<td class="label"><strong>URL 2:</strong></td>
<td class="field">
<input type="text" name="URL2" value="" size="30" id="URL2" />
</td>
</tr>	
		 					
<tr id="contextualdescription3"  style="display:none">
<td class="label"><strong>Description Part 3:</strong></td>
<td class="field">
<textarea id="DESCRIPTION3" name="DESCRIPTION3" cols="30" rows="2">
</textarea>
</td>
</tr>				
		
<tr id="contextualtitle3"  style="display:none">
<td class="label"><strong>Keyword 3:</strong></td>
<td class="field">
<input type="text" name="TITLE3" value="" size="30" id="TITLE3" />
</td>
</tr>						
	
<tr id="contextuallink3"  style="display:none">
<td class="label"><strong>URL 3:</strong></td>
<td class="field">
<input type="text" name="URL3" value="" size="30" id="URL3" />
</td>
</tr>		
		
<tr id="contextualdescription4"  style="display:none">
<td class="label"><strong>Description Part 4:</strong>
</td>
<td class="field">
<textarea id="DESCRIPTION4" name="DESCRIPTION4" cols="30" rows="2">
</textarea>
</td>
</tr>
{literal}
<script type="text/javascript">
<!-- 
updateContextualPreview() ;
-->
</script>
{/literal}

4. Still in submit.tpl,
FIND:

<input type="radio" name="LINK_TYPE" value="featured"
 {if $LINK_TYPE eq 'featured'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="featured"
 {if $LINK_TYPE eq 'featured'}checked="true"{/if}
  onclick="featured();"; >

FIND:

<input type="radio" name="LINK_TYPE" value="normal"
 {if $LINK_TYPE eq 'normal'}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="normal"
 {if $LINK_TYPE eq 'normal'}checked="true"{/if}
 onclick="regular();"; >

There are 2 Instances of this, for free and paid regular links.

FIND:

<input type="radio" name="LINK_TYPE" value="reciprocal"
 {if $LINK_TYPE eq reciprocal}checked="true"{/if}>

REPLACE BY:

<input type="radio" name="LINK_TYPE" value="reciprocal"
 {if $LINK_TYPE eq reciprocal}checked="true"{/if}
 onclick="reciprocal();"; >

There are 3 Instances of this, for different types of reciprocal links.

Please continue to step 3.

If you liked this MOD, and want to show your appreciation, you can link back to
rakCha : http://www.rakcha.com
or
enQuira : http://www.enquira.com

This step adds the required fields to the database. In this tutorial we assume that we provide 3 contextual deep links. As a result we will need to divide the paragraph that will contain the deep links into 4 parts.

The fields can be added using one of the following methods:
Method 1:
1. Open include/tables.php
FIND:

'RECPR_EXPIRED' => 'L NOTNULL DEFAULT 0'

REPLACE BY:

'RECPR_EXPIRED' => 'L NOTNULL DEFAULT 0' ,
'TITLE1' => 'C(255) NULL' ,
'URL1' => 'C(255) NULL' ,
'TITLE2' => 'C(255) NULL' ,
'URL2' => 'C(255) NULL' ,
'TITLE3' => 'C(255) NULL' ,
'URL3' => 'C(255) NULL' ,
'DESCRIPTION1'        => 'X2 NULL'  ,
'DESCRIPTION2'        => 'X2 NULL'  ,
'DESCRIPTION3'        => 'X2 NULL'  ,
'DESCRIPTION4'        => 'X2 NULL'

2. Rerun the installer by pointing to install/index.php. You will have to put that file back in the server since you most probably have deleted it or renamed it. You will also have to set writing permissions to include/config.php temporarily. this installer will update the table structure and add the new fields.

3. Remove the file install/index.php and the writing permissions on config.php

Method 2:
You can import the additional fields to the database in phpMyadmin. Create a text file fields.sql with the following content:

ALTER TABLE `PLD_LINK` ADD `TITLE1` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `TITLE2` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `TITLE3` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `URL1` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `URL2` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `URL3` TEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION1` LONGTEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION2` LONGTEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION3` LONGTEXT NULL ;
ALTER TABLE `PLD_LINK` ADD `DESCRIPTION4` LONGTEXT NULL ;

And import it in phpMyadmin.

Please continue to step 2.

If you liked this MOD, and want to show your appreciation, you can link back to
rakCha : http://www.rakcha.com
or
enQuira : http://www.enquira.com

June 7th, 2007phpld - Sort by Date

This adds another sorting option for directory listings. Using this simple modification you can sort listings by date.
Just 2 files need to be modified: main.tpl and /admin/conf_options.php

in main.tpl,
Locate

After that, ADD

{if $sort eq 'D'} | <span class="sort">{l}Date{/l}</span>{else} | 
<a href="?s=D{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}
{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}
{if !empty($p)}&amp;p={$p}{/if}">{l}Date{/mgУ6FS

in conf_options.php
FIND

'OPTIONS'  => array(
                 'P' => _L('PageRank')    ,
                 'H' => _L('Hits')        ,
                 'A' => _L('Alphabetical')
                 ),

REPLACE BY

'OPTIONS'  => array(
                 'D' => _L('Date')    ,
                 'P' => _L('PageRank')    ,
                 'H' => _L('Hits')        ,
                 'A' => _L('Alphabetical')
                 ),

You are done!

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!

April 25th, 2007phpld Image Uploader MOD

With this modification you can allow users to upload a profile image that will be placed in their details page.

1. Create a folder called uploads in the same folder as submit.php (root of the directory)
2. chmod 777 uploads
3. create a file image_upload.php in the same folder as submit.php, with the content below:

<?php 

$error=$_FILES["IMAGE"]["error"];
if ($error == UPLOAD_ERR_OK) {
 $parsed = parse_url($_POST["URL"]);
 $image_domain = $parsed['host'];
 $image_type=$_FILES['IMAGE']['type'];
 $image_loc="uploads/".$image_domain.".jpg";
 $tmp_name = $_FILES["IMAGE"]["tmp_name"];
  if ($image_type =="image/pjpeg" ||
      $image_type =="image/jpeg" ||
      $image_type=="image/gif"    ||
      $image_type=="image/png"){ 
    move_uploaded_file($tmp_name, $image_loc);
  }	
}

?>

4. in submit.php,
AFTER: require_once 'init.php';
ADD: require_once "image_upload.php";

5. in submit.tpl

FIND :

<form action="" method="post">

REPLACE BY:

<form action="" method="post"
          enctype="multipart/form-data">

FIND:

<td class="field">
      {* Load category selection *}
      {include file="category_select.tpl"}
   </td>
   </tr>

AFTER it, ADD:

<tr>
 <td class="label">Image</td>
 <td class="field">
  <input type="file" name="IMAGE" />
 </td>
</tr>

7. in detail.tpl, where you want the image to appear.
ADD:

{php}
$uploads_path="/path/to/uploads/";
$parsed = parse_url($this->_tpl_vars[URL]);
$image_domain = $parsed['host'];
$abs_image_loc = $uploads_path.$image_domain.".jpg";
$image_loc = "../uploads/".$image_domain.".jpg";
if (file_exists($abs_image_loc)) {
  echo "<img src=\"" . $image_loc . "\" />";
}
{/php}

EDIT : $uploads_path=”/path/to/uploads/”;
in the code above to something to the absolute path
to your uploads folder something like
“/home/domain/public_html/uploads/”

That’s it.
The mod can be improved by adding small test on the image size and dimensions.

Install the phpld deeplinks mod before applying the modification below.

To validate the additional deeplinks you will have to add the following:

First in submit.php
AFTER:

SmartyValidate :: register_validator('v_URL',
'URL','isURL', false, false, 'trim', 'submit_link');

ADD:

SmartyValidate :: register_validator('v_URL1',
 'URL1','isURL',true,false,'trim','submit_link');
SmartyValidate :: register_validator('v_URL1_ONLINE',
 'URL1','isURLOnline',true,false,null,'submit_link');

FINALLY in submit.tpl
AFTER:

<input type="text" name="URL1"
value="{$URL1|escape|trim}" size="40"
 maxlength="255" class="text"/>

ADD:

{validate form="submit_link" id="v_URL1"
 message=$smarty.capture.invalid_url}
{validate form="submit_link" id="v_URL1_ONLINE"
 message=$smarty.capture.url_not_online}

This will allow to validate the URL1 field when it is not empty. You should do the same for all URLs that you want to validate (straightforward).


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