Forums

Form within an article. Set dynamic subject to article title

trevzo 18 Dec, 2008
Hi Folks ๐Ÿ˜€

I have a chrono form within an article.
I wish to have the โ€œhostโ€ article title as a hidden dynamic subject field.

Please can anyone tell me if this is possible and give me some advice on how to do it?

Best wishes,
Trev
trevzo 18 Dec, 2008
Should I edit the form code to add the hidden field?
I donโ€™t know the php code to grab the article title.
GreyHead 18 Dec, 2008
Hi Trev,

I think that it's probably possible, there is an article object you can access and that the article title is one of the parameters in the object.

It may also be possible to use the ItemId to access the info - I think there has been some recent discussion about that in the forums here.

Bob
trevzo 18 Dec, 2008
Thanks for the quick reply Bob ๐Ÿ™‚

I was searching the forum for help prior to posting; I couldnโ€™t seem to find a solution that I could understand. I'm not very bright ๐Ÿคฃ

I am assuming that for my page to be displayed the main Joomla DB has already been queried to produce a report. ie my section blog

I thought it would just be a case of adding the hidden field to the form html code
Then adding something like

<? Echo โ€œtitle WHERE title = '$title '"; ?>

to get the value.

I hope I have explained this right

Trev
GreyHead 18 Dec, 2008
Hi trevzo,

Well yes, that's pretty much correct. Unfortunately there isn't a variable called $title that you can use. But there might be one that's called something like $this->article->params->title. You just need to find out exactly what it is called.

Bob
dustdog 13 Jan, 2009
Hi,
I also tried this. I got it to work somehow with this in a hidden field:
<?php
$mydoc =& JFactory::getDocument();
$mytitle = $mydoc->$params->get('title');
echo $mytitle;
?>

But my problem is that the article-title isn't shown but the category title... I guess it's not a Chronoforms-thing, but I didn't where tot post such a specific problem.
BTW, when I try to implement
$this->article->params->title
I get the obvious error because the form is linked through the plugin and is not a part of the article itself.

Maybe someone has a brilliant solution? :?

Dustdog
Max_admin 13 Jan, 2009
Hi,

earlier I couldn't find any way to get this except by making a query to the content table using the id variable coming to the page, if somebody can get it any other way then let me know!๐Ÿ™‚

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dustdog 14 Jan, 2009
Mmm, was affraid that it would be something like that...
Could you share the query syntax, I'm not such a coder :wink:
Thanks!

Cheers,
Dustdog
Max_admin 14 Jan, 2009
Sure!๐Ÿ™‚


$database =& JFactory::getDBO();
$query = "SELECT * FROM #__content WHERE id='".JRequest::getVar('id')."'";
$database->setQuery( $query );
$article = $database->loadObject();
echo $article->title;


Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dustdog 15 Jan, 2009
Works perfectly!! ๐Ÿ˜€
Thanks Max!!

Cheers,
Dustdog
novecento 09 Jun, 2009
Sorry,
were i have to insert this code?
Thanks
dustdog 10 Jun, 2009
Just put in the beginning of your formcode like I used it for a hidden field:
<table width="500" border="0" cellspacing="0" cellpadding="5">
<tr>
    <td width="200" valign="top">Vacature-naam</td>
    <td valign="top">
<?php
$database =& JFactory::getDBO();
$query = "SELECT * FROM #__content WHERE id='".JRequest::getVar('id')."'";
$database->setQuery( $query );
$article = $database->loadObject();
echo $article->title;
?>
<input type="hidden" name="vacature" value="<?php echo $article->title; ?>" />
</td>
  </tr>
</table>


It should do the trick.
Cheers,
Dustdog
GreyHead 10 Jun, 2009
Hi novcento,

It depends what you want to do - I think there it was being used in the Form HTML to set the value of a hidden field.

Bob
novecento 10 Jun, 2009
Thanks for the answers, i miss the "Form HTML"๐Ÿ™‚
This topic is locked and no more replies can be posted.