<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
//echo '<div>$doc->title :'.print_r($doc->title, true).'</div>';
?>
<input type='hidden' name='doc_title' value='<?=$doc->title?>' />
Forums
output current page title and category
You should be able to get the category id from the page url
<?php
$catid = JRequest::getInt('catid', '', 'get');
?>
But note that this will only work if the underlying url includes the category id, you may need to add code to handle the case where no value is found.
Bob
You can look the title up from the id
<?php
$catid = JRequest::getInt('catid', '', 'get');
$db =& JFactory::getDBO();
$query = "
SELECT `title`
FROM `#__categories`
WHERE `id` = $catid ;
";
$db->setQuery($query);
$title = $db->loadResult();
?>
Bob
<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
//echo '<div>$doc->title :'.print_r($doc->title, true).'</div>';
?>
<?php
$catid = JRequest::getInt('catid', '', 'get');
$db =& JFactory::getDBO();
$query = "
SELECT `title`
FROM `#__categories`
WHERE `id` = $catid ;
";
$db->setQuery($query);
$cattitle = $db->loadResult();
?>
<input type='hidden' name='doc_title' value='<?=$doc->title?>' />
<input type='hidden' name='cat_title' value='<?=$cattitle?>' />
...and here is what I am getting for debug output. The category title is not submitted correctly in the emails either.
1. Form passed first SPAM check OK
2. Form passed the submissions limit (if enabled) OK
3. Form passed the Image verification (if enabled) OK
4. Form passed the server side validation (if enabled) OK
5. $_POST Array: Array ( [name] => name [email] => [email]me@gmail.com[/email] [phone] => 111-111-1111 [resume] => test [message] => test [chrono_verification] => jxvut [button_8] => Submit [doc_title] => Document Title [cat_title] => [80612a62d3aa91cd6198efd61a3630f9] => 1 [1cf1] => 3bfc61f04c7ab9e7db1f36bdf9d1ad32 [chronoformname] => test_careers )
6. $_FILES Array: Array ( [upload] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
7. Form passed the plugins step (if enabled) OK
8. An email has been SENT successfully from xxx [email]noreply@domian.org[/email] to [email]me@gmail.com[/email]
9. Debug End
Odd, I just ran a quick test with the code on my site and it appears to pick up the Category Title OK.
By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.
Bob
I couldn't get any useful information from the page URL -- I don't know why :-( All that is available (or all I could find) is the Menu title as the Page title.
I was able to use this to build a complex MySQL query to get the page link from the jos_menus table, the article id from the link, the category id from the jos_content table and then the Category name from the jos_categories table.
<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
$db =& JFactory::getDBO();
$query = "
SELECT `title`
FROM `#__categories` WHERE `id` = (
SELECT `catid`
FROM `#__content`
WHERE `id` = (
SELECT SUBSTR(`link` FROM LOCATE('&id=',`link`)+4 )
FROM `#__menu`
WHERE `name` = ".$db->quote($doc->title)."
)
);
";
$db->setQuery($query);
$cattitle = $db->loadResult();
?>
<input type='hidden' name='doc_title' value='<?php echo $doc->title; ?>' />
<input type='hidden' name='cat_title' value='<?php echo $cattitle; ?>' />
There has to be a better way!
Bob
PS You can see the result in the 'Volunteers Accepted' article.
1. Form passed first SPAM check OK
2. Form passed the submissions limit (if enabled) OK
3. Form passed the Image verification (if enabled) OK
4. Form passed the server side validation (if enabled) OK
5. $_POST Array: Array ( [name] => me [email] => [email]me@me.com[/email] [phone] => 111 [resume] => [message] => 111 [chrono_verification] => aqwy4 [button_8] => Submit [doc_title] => Page Title [cat_title] => [27fe351265461a938ffc7a099214321b] => 1 [1cf1] => a54c1fae12dc916ac2038182a8fd76d3 [chronoformname] => test_careers )
6. $_FILES Array: Array ( [upload] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
7. Form passed the plugins step (if enabled) OK
8. An email has been SENT successfully from (The Website)noreply@me.org to [email]me@gmail.com[/email]
9. Debug End