My apologies, but I left out a critical element from the code in my last post. If you use the code I originally posted, it will write ALL of your Texty’s into a single page.

I should have included a line that will compare the actual URL with the values from your JSON feed to determine whether or not to write a particular Texty:

if (val==winval){
document.writeln(Texty);
}

Here’s the corrected code (I’ve also corrected the code in the original post):

<html>

<head>

//Optional: Your default page title, which can be changed based on the Texty you include

<title> Your Site Title </title>

//Load your JSON feed from your Zoho Creator application:

<script type=”text/javascript” src=”http://creator.zoho.com/ {Username} /json/ {View number} / {Private Link – Optional} /”></script>

<script type=”text/javascript” src=”/Documents/AjaxIncludes.txt”></script>

</head>

<body>

<script>
ajaxincludes(“banner.htm”);
ajaxincludes(“navigation.htm”);
</script>

<!–Identify and Insert the appropriate Texty from your list here–>

<script>

//Identify the parameters passed through the URL:

// Example – http://lockworldherald.com/Documents/articles.aspx?Home

var winloc=””+top.window.location;
var winsplit=winloc.split(“?”);

//If a value is found, match it to the appropriate Texty script from your Zoho Creator database

if (winsplit.length>1) {
for (var i=0; i<zoho{Username}view{View Number}.{Form Name}.length; i++){
var NewArray=zoho{Username}view{View Number}.{Form Name}[i];
var val=NewArray.Value;
var Texty=NewArray.TextyCode;

//It is a good idea to convert everything to lowercase, since javascript is case-sensitive. This way, if your page value is “superman,” your user could enter “Superman,” “SUPERMAN,” or “superman” and still get the the correct page:

val = val.toLowerCase();
var winval = winsplit[1].toLowerCase();

//Updated code begins here

if (val==winval){
document.writeln(Texty);
}

//End updated coce

//If you choose to change the Page Title for your records, include this code:

if (NewArray.Page_title>””) {
document.title=NewArray.Page_title;
}
}
}

//It is a good idea to add something here in case someone fails to enter a parameter into the page. Either redirect them to a page which will always exist, or else put the script for a fixed Texty here.

else {
location.replace(“http://yoursite.com/Documents/Testy.aspx?Value“);

// OR

document.writeln(‘<scr ‘+’ ipt type=”text/javascript” language=”javascript” src=”http://texty.com/cms/syndicate/ {Your Unique URL} .js”></scr ‘+’ ipt>’);

//NOTE: If you want to include the Texty within this code, you have to make sure you split up the <script> and </script> tags as I have done in the example above. Otherwise, your browser may get confused between a document.writeln(“</script>”); and a regular </script>, which can cause your javascript code to cease functioning.

}

</script>

<!–End Texty Script–>

<script>

ajaxincludes(“footer.htm”);

</script>

</body>

</html>

Leave a Reply:

Your email address will not be published. Required fields are marked *


*