Return to Snippet

Revision: 38042
at December 23, 2010 04:37 by powerthru


Initial Code
<?
var theTitle = "Join more than 216,249 Americans who want bold action on climate change.";

var tracking_code = salsa.getParameter("code");
if(tracking_code == "") tracking_code = 'none';

//this gets some parameters from the URL

function getTitle(){

var where = Request.getURI() ;
var match = /[a-zA-Z0-9\-]+$/i.exec(where);

if(match != null) {
	var shorturl = /[a-zA-Z0-9\-]+$/i.exec(where);
	var orderBy = 'Last_Modified DESC';
	var conditions = [ new Condition('slug', 'IN', shorturl)];
        var items = db.getObjects('publish', conditions, orderBy);
        for each (item in items) {
         var table = db.getObject('database_table', item.database_table_KEY);
         var ref = db.getObject(table.table_name, item.table_KEY);
            print(ref.Reference_Name);
        }
} else {
var lists =Request.getParameterList();
for each (list in lists) {
     if(list.name == 'action_KEY'){
         var camp=db.getObject("action",list.value);
         print(camp.Reference_Name);
     }  else if(list.name == 'donate_page_KEY') {
         var camp=db.getObject("donate_page",list.value);
         print(camp.Reference_Name);
     }  else if(list.name == 'tell_a_friend_KEY') {
         var camp=db.getObject("tell_a_friend",list.value);
         print(camp.Reference_Name);
     } else {
        print(theTitle);
    }
}

}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>1Sky | <?=getTitle()?></title>

Initial URL

                                

Initial Description
This was developed for 1Sky to write out titles to the template.  Thsi signle template can handle many DIA pages.  (Donation, Action, TAF).  It can determine what kind of page it is on by reading the URL and can even handle short URLs

Initial Title
SALSA Template Script to generate dynamic titles

Initial Tags

                                

Initial Language
JavaScript