Forums

Is there a way to go from form to Article?

fbc 13 May, 2008
Before I waste any time and install the component, I was wondering if there was anyway to go from form to article? Using a template?

Like I wanted people to submit poetry to a section of my joomla 1.5 site.

Once they hit the submit button I would like for the poem to appear as an article in a specific format like:

Poem name= article title & altertnate title

Article Body = Poem + sumitted by <name> + etc.etc.etc

Can it be done with this?
GreyHead 13 May, 2008
Hi fbc,

It's possible but not 'built-in'. You;d need to find or write the code to save the results into the articles table.

Bob
fbc 13 May, 2008
Awesome!! thanks.. I will look for the code..

any hints of where to start looking? article name?
GreyHead 14 May, 2008
Hi fbc,

There's been a recent thread about posting from a form into the FireBoard forums. The code there would be a good starting place, then you'll need to dig into the Joomla code to find out which tables need to be updated to post a new article.

Bob
fbc 14 May, 2008
great! I'll check it out.
fbc 16 May, 2008
This a piece of code another program uses to create content in joomla. What would I need to alter to make it write the form data to jcontent?

	$db =& JFactory::getDBO();

	//extraemos la noticia

	$query = "SELECT * FROM #__periodico_noticia WHERE IDNoticia = '$nid'";

	$db->setQuery( $query );

	$noticia = $db->loadObject();

	

	//construimos la consulta para insertarla como contenido en Joomla

	$query = "INSERT INTO #__content(title,alias,title_alias,introtext,sectionid,catid,state,created,publish_up) VALUES ("

		. "'$noticia->Titulo',"

		. "'$noticia->Titulo',"

		. "'$noticia->Link',"

		. "'$noticia->Descripcion',"

		. "'$sid',"

		. "'$cid',"

		. "'$noticia->published',"

		. "'$noticia->Fecha_de_publicacion',"

		. "'$noticia->Fecha_de_publicacion'"

		. ")";

	$db->setQuery( $query );

	

	//ejecutamos la consulta

	$db->query();

	//si todo va bien devolvemos cero 

	return 0;
fbc 17 May, 2008
OK In the form html area I got this:

input class="inputbox" name="title"
 id="title" size="50" maxlength="100" value=""
 type="text"


in the On Submit code - before sending email section i got:


 $db =& JFactory::getDBO(); 
    $query = "INSERT INTO #__content(title,alias,title_alias,introtext,sectionid,catid,state,created,publish_up) VALUES (" 
 
        . "'$title'," 
 
        . "'$title'," 
 
        . "'$title'," 
 
        . "'$introtext'," 
 
        . "'3'," 
 
        . "'$catid'," 
 
        . "'1'," 
 
        . "'2008-05-04 20:16:44'," 
 
        . "'2008-05-04 20:16:44'" 
 
        . ")"; 
 
    $db->setQuery( $query ); 
 
     
 
    //execute the query
 
    $db->query(); 
 
    //if everything goes well the result is zero  
 
    return 0;


And it just creates a record with the dates section id and correct state, but all the other fields are blank. The variables are not being passed. What should I do? Any recommendations?
fbc 17 May, 2008
OK it all works now, I figured it all out. Now I'm trying to get the text entered into the form to retain it's formatting. When it's saved to the table, it's saved as one long string. No linefeeds or nothing.. Just one long string of line together with no carriage returns or nothing.
This topic is locked and no more replies can be posted.