Forums

How to get HTML Code into the Text Editor with SubmitContent

dkartuzinski 26 May, 2009
Hi. I have been trying to get SubmitContentForm to work for my site.

Below is the HTML Code that is a Prototype of the Content I want to create for my site.

<!-- begin of hotellistingdiv -->
<div id="hotellistingdiv">
<!-- link -->
<a href="mon-hotel/hotel-exemple.html">
<!-- fldr name --><!--image --><!--ALT = NAME OF HOTEL -->   <!--Title = NAME OF HOTEL-->
<img src="images/Hotels/example/listingpic.jpg" alt="Example Hotel" title="Example Hotel" width="118" height="118" lang="fr" /></a>
<h4>
<!-- link --> <!--Name of Hotel--> <!-- hotel categorie -->
<a href="mon-hotel/hotel-exemple.html"><span class="pinkltrs">Mon Hotel –</span></a> 4*</h4>
<!-- address line -->
1 Rue d’Argentine, Paris 16ème<br />
<!--Intro paragraph -->
<p>C’est derrière la façade d’une maison de ville traditionnelle que se cache le Mon Hôtel, élégant boutique hôtel design. Cet hôtel est une adresse raffinée et intime, privilégiée de part son emplacement entre les Champs-Élysées et l’Arc de Triomphe.<br /> 
</p>
</div>
<!-- end of hotellistingdiv -->


Below is the CODE from the "FORM CODE" of Chronoforms: (I used the wizard and just copy/pasted it above the ContentSubmitForm)

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Hotel Name</label>
    <input class="cf_inputbox required" maxlength="150" size="50" title="" id="text_0" name="hotelname" type="text" />
  <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Hotel Name :: Please enter the name of the Hotel</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Folder Name of Images</label>
    <input class="cf_inputbox required" maxlength="150" size="50" title="" id="text_1" name="fldrname" type="text" />
  <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Folder Name of Images :: Please enter the name exactly of the folder for the images</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_fileupload">
    <label class="cf_label" style="width: 150px;">Upload Hotel Listing Image</label>
    <input class="cf_fileinput cf_inputbox required" title="" size="20" id="file_2" name="listingimg" type="file" />
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Upload Hotel Listing Image :: Please upload the image for the Hotel Listing</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_radiobutton">
    <label class="cf_label" style="width: 150px;">Hotel Category</label>
    <div class="float_left">
      <input value="Hôtel 4-étoiles" title="" class="radio validate-one-required" id="radio00" name="radio0" type="radio" />
      <label for="radio00" class="radio_label">Hôtel 4-étoiles</label>
      <br />
      
<input value="Hôtel 5-étoiles" title="" class="radio validate-one-required" id="radio01" name="radio0" type="radio" />
      <label for="radio01" class="radio_label">Hôtel 5-étoiles</label>
      <br />
      
<input value="Boutique Hôtel" title="" class="radio validate-one-required" id="radio02" name="radio0" type="radio" />
      <label for="radio02" class="radio_label">Boutique Hôtel</label>
      <br />
      

    </div>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Hotel Category :: Please choose one category for the hotel</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Hotel Address</label>
    <input class="cf_inputbox required" maxlength="150" size="50" title="" id="text_4" name="address" type="text" />
  <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Hotel Address :: Please enter the address as you would like it to appear</div>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 150px;">Intro Paragraph</label>
    <textarea class="cf_inputbox required" rows="4" id="text_5" title="" cols="50" name="intropara"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Intro Paragraph :: Please type in the introduction paragraph</div>
  </div>
  <div class="cfclear"> </div>
</div>


<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="button_6" type="submit" /><input type="reset" value="Reset"/>
  </div>
  <div class="cfclear"> </div>
</div>




<div  class="form_item"><div class="form_element cf_heading"><h1 id="" class="cf_text">Got a story ? Submit it!</h1></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_text"><span class="cf_text">With ChronoForms V3.0 out, new possibilities are achievable, using this form, users can submit their content to the chronoengine.com website! =)</span></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_heading"><h3 id="" class="cf_text">Please submit something meaningful or it will be deleted, no "blah blah" text or so!</h3></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Title:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_5" name="title" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" width="16" border="0" height="16"></a><div  class="tooltipdiv">Title: :: Your story title please!</div></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textarea" style="width:600px;"><label class="cf_label">Story body:</label>
<?php
$editor		=& JFactory::getEditor();
echo $editor->display( 'fulltext',  '' , '80%', '350', '55', '20', false ) ;

?>

</div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Your name:</label><input class="cf_inputbox required validate-alpha" maxlength="15" size="30" id="text_7" name="created_by_alias" type="text"><a onclick="return false;" class="tooltiplink"><img  src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" width="16" border="0" height="16"></a><div  class="tooltipdiv">Your name: :: Your nickname as you like it to appear with the story!</div></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_captcha"><label class="cf_label">Enter code as shown</label><span>{imageverification}</span></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_button"><input value="Submit Story" name="undefined" type="submit"></div><div class="clear"> </div></div>


Below is the code for "On Submit code - after sending email:"

<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'] = '1';
$_POST['id'] = '';
$_POST['sectionid'] = '1';
$_POST['state'] = '0';
$_POST['created'] = date("Y-m-d H:i:s");
?>


-------------

NOTE: I am using Joomla 1.5.10, text editor off, and the paid latest version of Chronoforms.

The idea is the use a bit of PHP to take the answers from the form and input it where the answers go in the HTML code above.

<?php echo "Hotel Name: " . $bla . "."; ?>

NOTE: I am getting a completely UNLABELLED, UNCATEGORIZED, CORRECT SECTION, BUT OTHERWISE COMPLETELY BLANK ARTICLE.

-------------

How to do I get the HTML code and the PHP echo statements into the text editor 'fulltext' or whatever, so that I can accomplish this?

Thanks.

-DK
dkartuzinski 27 May, 2009
This post below use a command in the code located on submit after sending email:

$fulltext_template = "<br /><br /><strong>{file_1}</strong><br /><br /><strong>{file_2}</strong>";

http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=13056

Can I put my template HTML with the {field names} like below:

$fulltext_template = "------- MY HTML AND FIELDS GO HERE---------";

How do I use this code to get my template rendered in the article? PLease please let me know.

$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="/components/com_chronocontact/uploads/showandtell/'.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=/components/com_chronocontact/uploads/showandtell/'.JRequest::getVar("file_2").'" target="_blank" ></p>', $fulltext_template);
JRequest::setVar("fulltext", $fulltext_template);
dkartuzinski 28 May, 2009
Hello. Seems like everyone was busy today. I've made some progress. I've been reading all through the forums and have managed to get some of what I need done, done.

http://www.chronoengine.com/forums.html?cont=posts&f=5&t=7570&p=33346#p33346

The above link goes to where you want to find out how to remove the added date and time to the upload file.

http://www.chronoengine.com/forums.html?cont=posts&f=2&t=13056

This above link is the one that helped me the most.

I use the below code to call the html code surrounding the form names (from the form):

$introtext_template = "<div id='hotellistingdiv'>{listingimg}<span class='pinkltrs'>{hotelname} –</span></a> {hotelcategory}</h4><br />{address}<br /><p>{intropara}<br /> </p></div>";


Then I used the following command, to replace the form elements with the answers.

$introtext_template = str_replace("{hotelname}", ''.JRequest::getVar("hotelname").'', $introtext_template);


After all of the ones from the form was treated with the above, I ended the PHP code with:

JRequest::setVar("introtext", $introtext_template);


I have three immediate questions and problems that if I solve will resolve 95% of the full eventual form (and keep me from getting removed from the project!):

I tried using the following code to recognize the uploaded file:

$introtext_template = str_replace("{listingmg}", ; <img src=../images/Hotels/'.JRequest::getVar("listingimg").'">', $introtext_template);


I get the following Parse error:

Parse error: syntax error, unexpected ';' in /homepages/24/d276107634/htdocs/joomla4/components/com_chronocontact/libraries/customcode.php(42) : eval()'d code on line 10

I tried reading in my PHP books (I am trying to learn PHP) and can't figure out what is wrong with my syntax. The image is saving to the property directory that it is set-up to deliver it to. Please read Question 2.

I am trying to upload the image, and then show it in the article.

Question #1: What do I fix in my code above to get it to upload the image without the Parse Error?

My full form and PHP code is below, but the next question, please.

Question #2: How do I create a unique folder to put the above image in, and to put subsequent images (later in the form) into? This form will eventually have over 10 images that will need to be uploaded. For the clients ease, the idea has been to keep the different types of image named the same and just put them into unique folders corresponding with the hotel/submission.

I imagine it has to do with creating a $fldrname = and concatenation with it with the PHP code, BUT considering I name my download path in the "File Uploads" part of the Chronoforms Form Management, I don't even know that that is correct.

My last question (for now :? ) is this:

Question #3: How do I call the Article Link within the article after it is submitting so that it can be used to go to the full article? The image {listingimg} and the hotel name {hotelname} as well as the {readmore} all need to be able to be clicked on and taken to the full article. Currently, I create the article and then copy the link and go back an paste it into the article. The must be a way to call the articles own URL to get it to go to the full article?

I am modifying submitcontent.bck (and so don't understand everything that is happening) but this is my FORM HTML:

<label class="cf_label">Hotel Title</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_5" name="title" type="text"><br />
<label for="hotelname">Hotel Name (to appear)</label>
<input name="hotelname" type="text" id="hotelname" title="hotelname" dir="ltr" lang="fr" size="50" maxlength="50" /><br />
<label for="listingimg">Please upload the Hotel Listing Image here.</label>
<input  name="listingimg" type="file" id="listingimg" title="listingimg" dir="ltr" lang="fr" size="150" /><br />
<select name="hotelcategory" size="1" id="hotelcategory" title="hotelcategory" dir="ltr" lang="fr">
   <option>Hôtel 4-étoiles</option>
   <option>Hôtel 5-étoiles</option>
   <option>Boutique Hôtel</option></select><br />
<label for="address">Address of the hotel.</label>
<input name="address" type="text" id="address" title="address" dir="ltr" lang="fr" size="50" maxlength="50" /><br />
<label for"intropara">Please type the Introduction paragraph for the hotel</label>
  <textarea name="intropara" cols="40" rows="4" id="intropara" title="intropara" dir="ltr" lang="fr" ></textarea><br />

<?php
$editor		=& JFactory::getEditor();
echo $editor->display( 'fulltext',  '' , '80%', '50', '55', '20', false ) ;?>
<div  class="form_item"><div class="form_element cf_button"><input value="Submit" name="undefined" type="submit"></div><div class="clear"> </div></div>


Below is the PHP code for "On Submit code - after sending email:"


<?php
$introtext_template = "<div id='hotellistingdiv'>{listingimg}<span class='pinkltrs'>{hotelname} –</span></a> {hotelcategory}</h4><br />{address}<br /><p>{intropara}<br /> </p></div>";

$introtext_template = str_replace("{hotelname}", ''.JRequest::getVar("hotelname").'', $introtext_template);

$introtext_template = str_replace("{hotelcategory}", ''.JRequest::getVar("hotelcategory").'', $introtext_template);

$introtext_template = str_replace("{fldrname}", ''.JRequest::getVar("fldrname").'', $introtext_template);

$introtext_template = str_replace("{listingmg}", ; <img src=../images/Hotels/'.JRequest::getVar("listingimg").'">', $introtext_template);

$introtext_template = str_replace("{address}", ''.JRequest::getVar("address").'', $introtext_template);

$introtext_template = str_replace("{intropara}", ''.JRequest::getVar("intropara").'', $introtext_template);

JRequest::setVar("introtext", $introtext_template);

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

NOTE:

I tried to enter the following snippets of code, but I only got errors even when I tried to convert them for my site.  They are from the above article.
$mydata = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
$introtext =$mydata['introtext'];
<?php
global $database, $my;
$query = "SELECT id FROM #__users WHERE id = '".$my->id."'";
$database->setQuery( $query );
$userdata = $database->loadObject($userdata);
?>
Thanks I really appreciate the help. I will probably have a few more questions, but the above would allow for me to get over 95% of the form done and working. Thank you. -DK ps. If you want to see the site about the hotels that I am working on, the best entry is:http://www.parisselect.fr/joomla4/hotels/
GreyHead 28 May, 2009
Hi dkartuzinski ,

The semi-colon problem is most likely the one in the middle of this line:
$introtext_template = str_replace("{listingmg}", ; <img src=../images/Hotels/'.JRequest::getVar("listingimg").'">', $introtext_template);
Try this version:
$introtext_template = str_replace("{listingmg}",  "<img src='../images/Hotels/".JRequest::getVar("listingimg")."' >", $introtext_template);


The code to use custom folders is in Emmanuel's image plugin I think, if not ask again and we can try to work it out.

I don't know how to preserve the page url though I think it has been discussed here.

Bob
dkartuzinski 28 May, 2009
Bob,

Thank you for your response and coding snippet. I copy/pasted it into the form and it didn't work.

I got the following error:

Parse error: syntax error, unexpected ';' in /homepages/24/d276107634/htdocs/joomla4/components/com_chronocontact/libraries/customcode.php(42) : eval()'d code on line 12

I tried removing the 1 semi-colon, just to see, but it didn't help at all.

The old code from the example from the post was:


$fulltext_template = str_replace("{file_1}", '<p><img style="max-width:500px;border:5px solid #eeeeee;" src="/components/com_chronocontact/uploads/showandtell/'.JRequest::getVar("file_1").'" target="_blank" ></p>', $fulltext_template);


I tried that and then started removing things I didn't I needed.

Below is the code again from my site that I am trying to make work (your version at this point!):

$introtext_template = str_replace("{listingmg}",  "<img src='../images/Hotels/".JRequest::getVar("listingimg")."' >", $introtext_template);


I tried to remove the ".." before the relative pathname, I also tried an absolute pathname.

Does the sequence of quotation marks and apostrophe's make any difference in this case? I tried to re-arrange their sequence and got this instead (it did not work):

$introtext_template = str_replace("{listingmg}", '<img src="
http://www.parisselect.fr/joomla4/images/Hotels/'.JRequest::getVar("listingimg").'" >', $introtext_template);

---

As far as creating a folder, perhaps the best solution is for the client to add prefixes representing each of her hotels and saving them that way. I rather have her do that then spend a lot more time on this folder issue. I found the image plug-in by Emmanuel. It looks great but later poster's commented on it not being compatible with the latest Chronoforms. Also it had a 3 image limitation, whereas I will have more than that. I did email him and hope that he has time to offer some advice.

Way more important is getting the image to show up.

---

I looked for "preserve url" in the forum and this post was the only post that came up. I am more than willing to go through and learn from the forums, but in this case I have no idea how to search for it. I have been in the forums the last 14 hours and haven't found anything searching with the strings I would look for it based on my understanding.

Any idea?

EDIT:

This code from Emmanuel's code may provide you with an idea of what he did. I know just one or two PHP lessons to know this is creating a variable to use to save the image in a folder. I just can't tell which are Global or temporary variables.

          $formname			= JRequest::getVar('chronoformname', 'unknown');
		$chronouploads 		        = "components/com_chronocontact/uploads/".$formname."/";
		$photo				= JRequest::getVar($params->photo, '', 'post', 'string', JREQUEST_ALLOWRAW);
		$quality			= $params->quality;
		$filein 			= $chronouploads.$photo;



Thanks for your help.

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