Forums

How to use On Submit code ?

dee-pack 24 Apr, 2010
hi everybody!

I try to create a simple form with:
a field for the title of the article (title of the book)
a field for writing a summary

So I want that these two fields display in an article.


I found in this forum a form to display information and image into an article.

But I don't understand how it works and so I can't alter it for what I want to do.

here is the on submit code
    <p><span style="color: #0000ff;"><strong>Thank you for submitting your article!</strong><br /><br /><a href="cm">Go back to my profile</a></span></p>

    <?php 

    $fulltext_template = "<br /><br /><strong>{file_1}</strong><br /><br /><strong>{file_2}</strong>";
    $fulltext_template = str_replace("{file_1}", '<p><img style="max-width:500px;border:5px solid #eeeeee;" src="/Portail/images/form/{form_name}'.JRequest::getVar("file_1").'" target="_blank" ></p>', $fulltext_template);
    $fulltext_template = str_replace("{file_2}", '<p><img style="max-width:500px;border:5px solid #eeeeee;" src="/Portail/images/form/{form_name}'.JRequest::getVar("file_2").'" target="_blank" ></p>', $fulltext_template);
    JRequest::setVar("fulltext", $fulltext_template);

    $_POST['catid'] = '44';
    $_POST['id'] = '';
    $_POST['sectionid'] = '8';
    $_POST['state'] = '1';
    $_POST['created'] = date("Y-m-d H:i:s");

        ?>


These code works, image are displayed in the article.

But I want to personalize this code.
For example, I want that the text (summary) displays in bold.
And I would like to display just above the text a message like "here the summary".

Could you tell me how to do that, because I have read a lot of tread and I don't find my answer.

thanks😉
GreyHead 24 Apr, 2010
Hi dee-pack,

To get a form to create an article please download the Submit Content form from the Downloads area here. That will give you a good start and the code you have found will make more sense.

Bob
dee-pack 24 Apr, 2010
I did it, but the code is not so clear.
<p><span style="color: #0000ff;"><strong>Thank you for submitting your story, we will review it shortly and if approved it will be published!</strong></span></p>
<p><strong>Cheers</strong></p>
<p><span style="text-decoration: underline;"><strong>ChronoEngine.com team!</strong></span></p>
<?php
$_POST['catid'] = '44';
$_POST['id'] = '';
$_POST['sectionid'] = '8';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");
?>


Which line decides that the text I wrote in the box has to be display in the article?
I think it's inside the <?php ?>, but where?


sorry for this noob question :/
GreyHead 24 Apr, 2010
Hi dee-pack,

Nothing there. The DB Connection saves the info to the Contents table in the database.

Bob
dee-pack 24 Apr, 2010
Hi Bob,
Ok I understand a little more.

But could you tell me how to display the text that I wrote in an article with bold style for example?
GreyHead 24 Apr, 2010
Hi dee-pack,

I'm not sure if you can. Possibly if you use a rich-text editor to create the post - there are insructions somewhere in the forusm for doing that.

Otherwise you would need to edit the article in the normal Joomla article editor; or use some fancy find and replace on the submitted text to add the <b>. . .</b> tags.

Bob
dee-pack 24 Apr, 2010
Ok I see. But it's not a real problem if I can't (Ok maybe I can, but I think it's a little too complex for me^^)

I have a bigger problem. In my form I have a heading (H3) and a text box.

what I have to do if I want that the heading keep his style (H3) when I submit it in a article?

Thanks for your help, I appreciate😉
GreyHead 24 Apr, 2010
Hi dee-pack,

Much the same as with the Bold, you'll need to add it to the text-area content. There is no H3 field for an article so everything has to be in fulltext or introtext.

Bob
This topic is locked and no more replies can be posted.