Is there a way to make the default to be published?
Quote from: landonpoburan at Oct 21, 2010, 09:00 PM
Is there a way to make the default to be published?
System -> System Settings -- published_default
or
$resource = $modx->newObject('modResource',array('pagetitle'=>'SomeTitle', 'published'=>'1'));
$resource->save();
or
$resource = $modx->newObject('modResource',array('pagetitle'=>'SomeTitle'));
$resource->set('published','1');
$resource->save();
Thanks that worked great.
Question:
Using formit I am storing values for a checkbox. So there can be more then one value, here is the formit code:
<input type="hidden" name="nominee_category:required" value="" />
<input id="nominee_category" type="radio" name="nominee_category:required" value="business" [[+fi.nominee_category:is=`business`:then=`checked="checked"`]] /> Business
<input id="nominee_category" type="radio" name="nominee_category:required" value="education: non-formal" [[+fi.nominee_category:is=`education: non-formal`:then=`checked="checked"`]] /> Education: Non-Formal
<input id="nominee_category" type="radio" name="nominee_category:required" value="education: school" [[+fi.nominee_category:is=`education: school`:then=`checked="checked"`]] /> Education: School or Classroom
<input id="nominee_category" type="radio" name="nominee_category:required" value="government institution" [[+fi.nominee_category:is=`government institution`:then=`checked="checked"`]] /> Government Institution
<input id="nominee_category" type="radio" name="nominee_category:required" value="individual commitment" [[+fi.nominee_category:is=`individual commitment`:then=`checked="checked"`]] /> Individual Commitment
<input id="nominee_category" type="radio" name="nominee_category:required" value="nonprofit" [[+fi.nominee_category:is=`nonprofit`:then=`checked="checked"`]] /> Not-For-Profit Association
<input id="nominee_category" type="radio" name="nominee_category:required" value="youth" [[+fi.nominee_category:is=`youth`:then=`checked="checked"`]] /> Youth
Then I have a page to displaying it using:
[[*nominee_category]]
But it just outputs "Array", how do I output the values?
The checkbox variable will be an array. You’re code will need to loop through that array and check each value.
See if one of these helps:
http://www.html-form-guide.com/php-form/php-form-checkbox.html
http://apptools.com/phptools/forms/forms3.php
Quote from: BobRay at Oct 23, 2010, 06:13 PM
The checkbox variable will be an array. You’re code will need to loop through that array and check each value.
See if one of these helps:
http://www.html-form-guide.com/php-form/php-form-checkbox.html
http://apptools.com/phptools/forms/forms3.php
Would putting the following in a snippet then referencing it in the template work:
$n = count($[[*emerald_hearabout]]);
for($i=0; $i < $b; $i++)
{
echo($[[*emerald_hearabout]][$i] . " ");
}
It should work if that’s the name of a checkbox group. BTW, the things in your code above are not checkboxes, they are radio buttons.
Quote from: BobRay at Oct 23, 2010, 06:27 PM
It should work if that’s the name of a checkbox group. BTW, the things in your code above are not checkboxes, they are radio buttons.
Sorry pasted wrong example. Here is the code I am using in the snippet:
$emerald = [[*emerald_hearabout]];
$n = count($emerald);
for($i=0; $i < $b; $i++)
{
echo($emerald[$i] . " ");
}
Then calling that snippet in the template but getting this error:
Parse error: syntax error, unexpected ’[’ in /home/emeraldfound/emeraldfoundation.ca/core/cache/elements/modsnippet/29.include.cache.php on line 7
Sorry, I didn’t notice this at first. You can’t use MODx tags in a snippet. You’d want something like:
$emerald = $emerald_hereabout
Quote from: BobRay at Oct 23, 2010, 06:48 PM
Sorry, I didn’t notice this at first. You can’t use MODx tags in a snippet. You’d want something like:
$emerald = $emerald_hereabout
Ok but how do I get the value of [[*emerald_hearabout]] in that variable?
Quote from: landonpoburan at Oct 23, 2010, 07:03 PM
Quote from: BobRay at Oct 23, 2010, 06:48 PM
Sorry, I didn’t notice this at first. You can’t use MODx tags in a snippet. You’d want something like:
$emerald = $emerald_hereabout
Ok but how do I get the value of [[*emerald_hearabout]] in that variable?
If it’s the name of an input field and the form’s method is "post" it should be in $_POST[’emerald_hearabout’].