Forums

Tip: Setting the Page Title when using the Chronoform plugin

ozneilau 03 May, 2016
You can usually set the Page Title using the following code:

<?php
  $document = JFactory::getDocument();
  $document->setTitle("my form page");
?>


but this doesn't seem to work if the ChronoForm is inserted into an article using the plugin.

To get around this issue, you can add a "Load JS" action to the "On Load" section with the following or similar code:

window.onload=function() {
  changeTitle ('<?php echo $form->data['my-form-title']; ?>')
}
function changeTitle (newTitle) {
  document.title=newTitle;            
}  


This works and apparently Google does crawl content injected by JavaScript. Other search engines may not see JavaScript injected content so this is probably not the best practice and this method is only recommended where there is no better way to update the Page Title.
This topic is locked and no more replies can be posted.