Hi Guys
I am trying to return the page title of a form inserted in an article with the plugin through a hidden field. Can anyone give me the code to use and where to locate it?
Regards
I am trying to return the page title of a form inserted in an article with the plugin through a hidden field. Can anyone give me the code to use and where to locate it?
Regards
Hi treblesix,
Try this:
Bob
Try this:
<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
?>
. . .
<input type='hidden' name='title' value='<?php echo $doc->getTitle(); ?>' />
Bob
This sounds perfect but I must be doing something wrong, do I need to add something to the email template?
Hi Greyhead. Thanks for the quick reply - well it's returning something now, but it seems to be returning the article catergory instead of the article title? Weird. Any ideas.
Hi crashtackle,
I think that $doc->getTitle() should give you the page title. But check the Joomla docs, I could be wrong.
Bob
I think that $doc->getTitle() should give you the page title. But check the Joomla docs, I could be wrong.
Bob
Thanks Greyhead. I really wouldn't know about that, but it would make sense...
I'll see if I can figure it out. Thank again for the fast support.
I'll see if I can figure it out. Thank again for the fast support.
Hi Greyhead
I'm also getting the article catergory instead of the pagetitle 😟
Do You have any other suggestions or ideas?
Regards Anders
I'm also getting the article catergory instead of the pagetitle 😟
Do You have any other suggestions or ideas?
Regards Anders
Hi Anders,
I've just checked the code and it works fine for me. I can't imagine why you'd get the category id from this. Here's the code I used in the Form HTML:
The echo line will show the value in the form if you uncomment it for debugging.
Bob
I've just checked the code and it works fine for me. I can't imagine why you'd get the category id from this. Here's the code I used in the Form HTML:
<?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?>' />
The echo line will show the value in the form if you uncomment it for debugging.
Bob
Hi Bob,
same problem here. I tried and tried and searched the whole web for the solution... but still, not the category title is returned ...but the Menu title. Seems weird, as the menu is not tagged with <title> at all. Please check the problem here:
http://www.himalaya.ch/wwwneu/index.php?option=com_content&view=article&id=203:tibetisches-neujahr-in-osttibet&catid=6:gruppenreisen&Itemid=5
The thing is, that there will be some 300 forms which have to return the page title...
Any help will be deeply appreciated. By the way: I'm using ChronoForms for years now, and nothing else even comes close or probably ever will 😀
Martin Scheidegger c/o marscom.ch
same problem here. I tried and tried and searched the whole web for the solution... but still, not the category title is returned ...but the Menu title. Seems weird, as the menu is not tagged with <title> at all. Please check the problem here:
http://www.himalaya.ch/wwwneu/index.php?option=com_content&view=article&id=203:tibetisches-neujahr-in-osttibet&catid=6:gruppenreisen&Itemid=5
The thing is, that there will be some 300 forms which have to return the page title...
Any help will be deeply appreciated. By the way: I'm using ChronoForms for years now, and nothing else even comes close or probably ever will 😀
Martin Scheidegger c/o marscom.ch
Hi Martin,
Have you tried pulling the Category id from the page URL?
Bob
Have you tried pulling the Category id from the page URL?
<?php
if ( $mainframe->isSite() ) {return; }
$catid = JRequest::getInt('catid', 0, 'get');
?>
. . .
<input type='hidden' name='catid' value='<?=$catid?>' />
You can then use the Category Id to get the Category name.Bob
Hi Bob,
I really appreciate your immediate reply! I feel honoured by your direct response, too 😀
But still, it won't work: there is no form output at all, when I try the above CatId proposal.
Please note, that I have to retrieve the title of the article, not the cat id. In reply of an older post, I mentioned this falsely. I need to automatically enter the page title (meaning: the title of the journey) in the respective form field. The reason is quite simple: some of the trips have similar titles, so the customers often confuse them ... and book the wrong one. With the automatic retrieve, this will be solved.
This code was used to test your proposal:
Actually, the page looks good, after having removed all requests:
http://www.himalaya.ch/wwwneu/index.php?option=com_content&view=article&id=203:tibetisches-neujahr-in-osttibet&catid=6:gruppenreisen&Itemid=5
When you look at the first form field, you see what would be needed in there...
As I'm definitively not a PHP crack, I spent five full hours this day to find a solution. By now, I know a lot more about JOOMLA's API, but obviously...not enough.
Thanks for every hint,
Martin
I really appreciate your immediate reply! I feel honoured by your direct response, too 😀
But still, it won't work: there is no form output at all, when I try the above CatId proposal.
Please note, that I have to retrieve the title of the article, not the cat id. In reply of an older post, I mentioned this falsely. I need to automatically enter the page title (meaning: the title of the journey) in the respective form field. The reason is quite simple: some of the trips have similar titles, so the customers often confuse them ... and book the wrong one. With the automatic retrieve, this will be solved.
This code was used to test your proposal:
<?php
if ( $mainframe->isSite() ) {return; }
$catid = JRequest::getInt('catid', 0, 'get');
?>
Anmeldung zu einer Reise<br/><br/>
<table width="450" border="0" cellspacing="0" cellpadding="4">
<tr>
<td>Reise</td>
<td><input type='text' name='catid' value='<?=$catid?>' /></td>
</tr>
<tr>
<td>Reisedatum</td>
<td><input style="border: 1px solid #545454; background: none;" name="Reisedatum" type="text" size="32"></td>
</tr>
... blah blah further form fields ...
<tr>
<td colspan="2">
<label>
<input name="Reiseangebote" type="checkbox" value="Wünscht aktuelle Reiseangebote" id="Reiseangebote" checked>
Bitte informieren Sie mich über aktuelle Reiseangebote</label></td>
</tr>
<tr>
<td valign="top">Bemerkungen</td>
<td valign="top"><textarea style="border: 1px solid #545454; background: none;" name="Bemerkungen" rows="5" cols="28"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Absenden"></td>
<td><input type="reset" value="Zuruecksetzen"></td>
</tr>
</table>
<p><br>
<strong>Ihre Anmeldung wird erst nach unserer Rückbestätigung (Telephon, Fax, E-Mail) verbindlich. </strong><br>
Es gelten unsere "Allgemeinen Reise- und Vertragsbedingungen".
</p>
Actually, the page looks good, after having removed all requests:
http://www.himalaya.ch/wwwneu/index.php?option=com_content&view=article&id=203:tibetisches-neujahr-in-osttibet&catid=6:gruppenreisen&Itemid=5
When you look at the first form field, you see what would be needed in there...
As I'm definitively not a PHP crack, I spent five full hours this day to find a solution. By now, I know a lot more about JOOMLA's API, but obviously...not enough.
Thanks for every hint,
Martin
Hi Martin,
This has been sitting in an open browser tab for a long time, my apologies.
I think that you may be able to recover the article 'id' using the code we had earlier and then use this to look in jos_content to get the corresponding title.
Bob
This has been sitting in an open browser tab for a long time, my apologies.
I think that you may be able to recover the article 'id' using the code we had earlier and then use this to look in jos_content to get the corresponding title.
Bob
Hello Martin,
I am having the same issue. I have a Hawaii activity website where I need to have the article title or article ID number show up in the email. I used the code provided and added it to the bottom of the form html but it did not work. Can you tell me if you were able to figure it out?
Mahalo,
Karen
I am having the same issue. I have a Hawaii activity website where I need to have the article title or article ID number show up in the email. I used the code provided and added it to the bottom of the form html but it did not work. Can you tell me if you were able to figure it out?
Mahalo,
Karen
Hi Karen - I added the following code at the end of the HTML section and it works just fine
<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
?>
<input type='hidden' name='title' value='<?php echo $doc->getTitle(); ?>' />
Thank you Martin. I've tried that but I still only get the category ID...not sure why. Perhpas it's because I have more than one article per category.
Karen
Karen
I was stumbling upon this article while trying to answer the same question put on the table here: How to get the page title or, and maybe this is for some reason the better question, how to get the article tile into one's submission form.
For some reason the page title doesn't work in some constellation, the page title turns to the category in the moment you hit the submit button,maybe because i linked my articles using a menü structure with category blog view.
But the answer is quite simple and was found on some Postings a year ago or so in this forum:
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=11976#p21234
there you find piece of code that makes it possible to avoid the page title but use the article title instead. You can easily combine it with those hidden Text box describes in this post:
You can comment out the "echo" in the last line of the first block to see if you're right at first sight.
I Just hope this helps the next one searching this forum for the answer :-).
For some reason the page title doesn't work in some constellation, the page title turns to the category in the moment you hit the submit button,maybe because i linked my articles using a menü structure with category blog view.
But the answer is quite simple and was found on some Postings a year ago or so in this forum:
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=11976#p21234
there you find piece of code that makes it possible to avoid the page title but use the article title instead. You can easily combine it with those hidden Text box describes in this post:
<?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='doc_title' value='<?=$article->title?>' />
You can comment out the "echo" in the last line of the first block to see if you're right at first sight.
I Just hope this helps the next one searching this forum for the answer :-).
Hi,
I have successfully returned the page Title, but now I am also interested in returning the current page URL. Here is the code I have placed within Form HTML:
I can't get it to work for some reason... any help would be appreciated!!
I have successfully returned the page Title, but now I am also interested in returning the current page URL. Here is the code I have placed within Form HTML:
<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
?>
<input type='hidden' name='title' value='<?php echo $doc->getTitle(); ?>' />
<?php
if ( !$mainframe->isSite() ) { return; }
$doc =& JFactory::getDocument();
?>
<input type='hidden' name='link' value='<?php echo $doc->getLink(); ?>' />
I can't get it to work for some reason... any help would be appreciated!!
Hi hunnbunnygem,
Try this
Bob
Try this
<?php
if ( !$mainframe->isSite() ) { return; }
$uri =& JFactory::getURI();
?>
<input type='hidden' name='uri' value='<?php echo $uri->toString(); ?>' />
Bob
Thank youuuu! Worked like a charm.
-Gemma
-Gemma
Hi all,
how can I get article created date and put it in input hidden?
Thanks.
how can I get article created date and put it in input hidden?
Thanks.
Hi filipetorres,
Get the article ID and look up the created date in the jos_content table.
Bob
Get the article ID and look up the created date in the jos_content table.
Bob
Super, but for some reason, from time to time, it stops, when i search the form code, i find that the title inclusion code disappears!!! weared isnt it, i am not sure if i am adding it to the right place or not, but i am adding it atthe bottom of the form html code, any suggestions?
This topic is locked and no more replies can be posted.