I am putting together a form that allows users to submit an article, but with custom fields.
First, I would like them to be able to choose which category (in a specific section) the article is submitted to. I got the dropdown box with the correct categories to appear using this code (formatted this way due to css styling):
<div class="form_item">
<div class="form_element">
<label class="cf_label">
<b>Category</b>
</label>
<?php
echo JHTML::_('list.category', 'field_name', '9');
?>
</div>
<div class="clear">
</div>
</div>However, when I do a test run to try to submit something to a category, it just goes to Uncategorized within that section. I assume the issue is in the code I have under On Submit after email, which is this:
<?php
$_POST['catid'] = ' ';
$_POST['id'] = ' ';
$_POST['sectionid'] = '9';
$_POST['state'] = '1';
$_POST['created'] = date("mm-dd-YYYY");
?>I simply don't know what to put instead of ' ' for catid. The search results I've found on here have been bits and pieces of the problem, and I haven't been able to mix and match solutions to correctly result in a Categories drop down box that appears the right way in the front end and actual successful submission to selected Category.
Second, while I can get whatever is typed into the HTML Editing box on the form to appear as an article, as well as the title and the username from Community Builder, I can't get any of the custom fields (and subsequent entries) to appear, either on the page as published information or as part of the saved article in the backend. Just a horizontal line and whatever was entered into the HTML box. I *think* I may have to edit core Joomla files to fix this, but I would just appreciate being pointed in the right direction if possible as to where to get the information on what files I need to hack into and edit, as I really have no idea.
Sorry for being such a beginner. I really appreciate this extension as well as the support! Thank you!
If you turnon debug in the form General tab you should be able to see what is being returned when the form is submitted.
In this case I think you will find that the category id you need shows up in a field called 'form_name' . . . probalby a first step is to rename this as 'catid' in the JHTML Line.
I'm not sure if this will solve the problem but it's a good step on the way.
Bob
I changed my Form Code to:
<!--CATEGORY SELECT--!>
<div class="form_item">
<div class="form_element">
<label class="cf_label">
<b>Category</b>
</label>
<?php
echo JHTML::_('list.category', 'catid', '9');
?>
</div>
<div class="clear">
</div>
</div>(where 9 = the section I am pulling categories from)
And simply changed the post-email On Submit code to:
<?php
$_POST['catid'];
$_POST['id'] = '';
$_POST['sectionid'] = '9';
$_POST['state'] = '1';
$_POST['created'] = date("mm-dd-YYYY");
?>Eliminating the blank field after catid. Simple enough, but good lord I tried a million different things. Thanks! This website is for a college midterm (in a non-computer class) in addition to being a pet project so I really appreciate things *actually* working!
Now if anyone could point me in the direction of the files I need to rewrite to make the custom fields appear, that's my next headache to sort out🙂
please check this post, the user has added pictures to the article, using the same technique you can add any type of data:
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=13056#p26629
Cheers
Max
Anyway, here's what my code looks like now:
<p><span style="color: #0000ff;"><strong>Thank you!</strong></p></span>
<p>Your story should be available on the website within 10 minutes. If it isn't up in an hour, please let us know: help@dollhouse-attic.com</p>
<p>If you need to edit, or add chapters, please see the Instructions for more information.</p>
<p>And don't forget to invite friends to read and review!</p>
<?php
$introtext = "
<strong><p>Author: {created_by}</strong></p>
<strong>Rating: </strong>{rating_1}<br>
<strong>Characters: </strong>{char1_1}/{char2_1}<br>
<strong>Summary: </strong>{summ_1}<br>
<strong>Status: </strong>{radio0}<br>";
$introtext = str_replace('{username}',
''.JRequest::getVar('created_by').'', $introtext);
$introtext = str_replace('{rating_1}',
''.JRequest::getVar('rating_1').'', $introtext);
$introtext = str_replace("{char1_1}",
''.JRequest::getVar("char2_1").'', $introtext);
$introtext = str_replace("{char2_1}",
''.JRequest::getVar("char2_1").'', $introtext);
$introtext = str_replace("{radio0}",
''.JRequest::getVar("radio0").'', $introtext);
$introtext = str_replace("{summ_1}",
''.JRequest::getVar("summ_1").'', $introtext);
JRequest::setVar('introtext', $introtext);
$fulltext_template = "<br>
<strong>Title: {title}</strong><br>
<strong>Author: {created_by}</strong><br>
<strong>Rating: </strong>{rating_1}<br>
<strong>Characters: </strong>{char1_1} and {char2_1}<br>
<strong>Status: </strong>{radio0}<br><br>
<strong>Summary: </strong>{summ_1}<br><p><br></p>
{fulltext}<br>";
$fulltext_template = str_replace("{title}",
''.JRequest::getVar("title").'',
$fulltext_template);
$fulltext_template = str_replace("{created_by}",
''.JRequest::getVar("username").'',
$fulltext_template);
$fulltext_template = str_replace("{rating_1}",
''.JRequest::getVar("rating_1").'',
$fulltext_template);
$fulltext_template = str_replace("{char1_1}",
''.JRequest::getVar("char1_1").'',
$fulltext_template);
$fulltext_template = str_replace("{char2_1}",
''.JRequest::getVar("char2_1").'',
$fulltext_template);
$fulltext_template = str_replace("{radio0}",
''.JRequest::getVar("radio0").'',
$fulltext_template);
$fulltext_template = str_replace("{summ_1}",
''.JRequest::getVar("summ_1").'',
$fulltext_template);
$fulltext_template = str_replace("{fulltext}",
''.JRequest::getVar("fulltext").'',
$fulltext_template);
JRequest::setVar("fulltext", $fulltext_template);
$_POST['catid'];
$_POST['id'] = '';
$_POST['sectionid'] = '9';
$_POST['state'] = '1';
$_POST['created'] = date("m-d-Y");
?>Any suggestions appreciated! Thank you so much!
Hard to tell what's happening from the code snippet - that looks OK, but I'm not sure about 'after the php tag'
[sendfb][/sendfb]
Bob
$mydata = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
$introtext =$mydata['introtext'];right after "<?php" but wasn't positive that was the right place.
I think I found it . . . the getVar() method filters the input by default as a security protection from site attacks. You can control this by using an extra parameter in getVar. The syntax is
mixed getVar (string $name, [string $default = null], [string $hash = 'default'], [string $type = 'none'], int $mask)
and $mask can take these values#
* @param int Filter bit mask. 1=no trim: If this flag is cleared and the input is a string, the string will have leading and trailing whitespace trimmed. 2=allow_raw: If set, no more filtering is performed, higher bits are ignored. 4=allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering is performed. If no bits other than the 1 bit is set, a strict filter is applied.
Bob
Again, I really appreciate all the assistance.
Sorry, it needs to go into the JRequest::getVar("fulltext") where you want to allow html. This would become
JRequest::getVar("fulltext", '', 'post', 'none', '4')If 4 doesn't do the trick then try 2 instead.Bob
Thank you so much for all your help!!
