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


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