Capturing Meta Page Title in form

jivy 17 May, 2012
Chronoforms: 4.0 RC3.3 Joomla 2.5.4

I have a single form that I use on multiple landing pages. The form has the following code that captures the page name and inserts it into a form field:
<?php
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
    $ids = explode(':',JRequest::getString('id'));
    $article_id = $ids[0];
    $article =& JTable::getInstance("content");
    $article->load($article_id);
    
}
?>
<input type='hidden' name='label:Form_Source_ID' maxlength='150' id='title' value='<?php echo $article->get ("title"); ?>' />
This works well when the visitor is directed to the landing page. However, I want to be able to allow registered users to navigate to the landing pages from a category list menu item. When I create a menu for the landing pages, the result is a completely blank page(not even the template) with "on line 15" in the top left hand corner. No other error message... no other nothing.

If I un-publish the form, then the menu works as normally expected. I have isolated the problem to the following line (line 15 of the form code):
===============
<input type='hidden' name='label:Form_Source_ID' maxlength='150' id='title' value='<?php echo $article->get ("title"); ?>' />
===============
Again, it works perfectly on the landing page, but it somehow blocks a category list menu.
GreyHead 17 May, 2012
HI Jivy,

Your code gets the 'article' title and will only work on article pages. A category list page doesn't have an 'article id'.

You can get the page title with:
<?php
$doc =& JFactory::getDocument();
$title = $doc->getTitle();
?>

Bob
This topic is locked and no more replies can be posted.