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