Jump to content
  • 0

Generate dynamic title & meta tags based on querystring?


cwjewell3

Question

I'm trying to generate dynamic title and meta tags based on a querystring. I would like the title tag to display the value for the following field I have in caspio [@field:Property_Name]. Ideally, the meta tag would be a combination of field values from caspio and static text (i.e. [@field:Best_Use] [@field:Property_Type] for [@field:Available_for] in [@field:Community], Virginia.)

Here is a sample details page http://www.yesmontgomeryva.org/crepages.htm?ID=10034&cbResetParam=1. If you look at the source for the page, the title tag and meta tags are not populating record data for these field.

Any help would be greatly appreciated.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi,

Assuming you were asking about Caspio rather than ExpressDB...

Problem is, you can't put a Caspio variable (like [@field:Property_Type]) into the external web page. It needs to go into the Caspio page so the Caspio server can interpret it.

But you mentioned the query string. If you can set it up so the Caspio field values are passing as parameters in the URL, then you can use Javascript to parse those parameters out of the URL and create HTML elements with those values.

You can google for info on parsing the URL query string with JS; there are a lot of articles on that.

Tim

Link to comment
Share on other sites

  • 0

This is the code we are using to set our Titles by passing two parameters from a previous page containing a DataPage with the fields in the URL. for example - http://www.eis-inc.com/suppliers/productdetail.asp?prod_nbr=620-3M&Catalog_Area=Tape%20Dispensers&SupCoName=3M%20EMD

If anyone has some additional tweaks, let me know. We have to use the unescape() in a few places because our Catalog Area and Supplier Name fields contain "spaces", which the URL ends up adding the escape character %20 which then needs to be removed.

<script>
function gup( name )
{  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^]*)";  
	var regex = new RegExp( regexS );  
	var results = regex.exec( window.location.href );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}
var catalog_param = gup( 'Catalog_Area' );
var supplier_param = gup( 'SupCoName' );
var varCatalog = catalog_param;
var varSupplier = supplier_param;
document.title =  unescape(varCatalog + ' Product List from EIS | ' + varSupplier);
</script>
Link to comment
Share on other sites

  • 0

try this one....

 

function getQueryVal(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

 

Full Source : Getting Query String Values

 

Balmer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...