Forums

Get article id in form

narsaw 17 Jan, 2009
Hi,

I am using Joomla 1.0

If I have link to a chronoengine form in one of my articles, how can I get the article title to passed to a text field to the chronoengine form.

Example.

Article Title = "How to make great forms"

In the above article I have a link that says "Contact me for more details", when the user clicks on this link, the "How to make great forms" get passed to a text (html) field.

I can code the html I just want to know how to get the "Article Title".

Again, I am using Joomla 1.0
GreyHead 17 Jan, 2009
Hi narswa,

Please search the forums; this has been posted and solved in the last week.

Bob
narsaw 18 Jan, 2009
Thanks for the link. However, I am getting an error (see below). Here is what my php looks like.

Again I am using Joomla 1.0, not sure if the JRequest is for 1.5 only.
<?php
global $database;
$query = "SELECT * FROM #__content WHERE id='".JRequest::getVar('id')."'";
$database->setQuery( $query );
$article = $database->loadObject();
echo $article->title;
?> 


ERROR:

Fatal error: Class 'JRequest' not found in /home/idahoea2/public_html/components/com_chronocontact/chronocontact.html.php(76) : eval()'d code on line 3
GreyHead 19 Jan, 2009
Hi narsaw,

Yes, JRequest is Joomla 1.5 only. For 1.0 use WHERE id='".$_POST['id']."'";
Bob
narsaw 19 Jan, 2009
Please pardon my inexperience here.

Here is the code I have:


<?php
global $database;
$query = "SELECT title from jos_content WHERE id='".$_POST['id']."'";
echo query;
$database->setQuery($query);
$title = $database->loadResult();
echo "Loading Title...";
echo $title;
?>


This code is in my chrono form. Obviuosly this code expects the $_POST[id] to contain some "id" to use in querying the database to get the article title.

My question is, where is this id coming from, in other words how does it get into the $_POST array for processing?


I thought about setting up a link like:

http://www.example.com/someForm.php?id=341


When I click on this link my query looks like:

SELECT title from jos_content WHERE id=
, notice id is left empty.

So what I need is a way to sending a chronoForm an article title or article id. The article title or id would come from the current article that the user is viewing.
Max_admin 19 Jan, 2009
hi, try to replace $_POST with $_REQUEST ?

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
narsaw 20 Jan, 2009

hi, try to replace $_POST with $_REQUEST ?

Max


Preliminary test would indicate that this works. I am do more testing later and post to this topic.

Genius Max ...

Thanks,
C
This topic is locked and no more replies can be posted.