Hey all this should be a pretty simple one...well I hope it is, I am trying to get the username/email for every user on my system ( using pnUserGetAll to accomplish this ) and in return I want to strip out the username and email address for the users and input those as my options for a drop down select. I have figured out how to get the userdata from the API reference, but I am not sure how to get the loop for the options in the select to work so that I get the username listed with the value of the email address for given user. I hope this makes sense.
Thanks
-SUNADMN
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 07:01 AM
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 06:41 AM
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 06:27 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
building select options from pnUserGetAll()??
-
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
You'd need to loop through the result set from the API to create an array suitable for the html_options plugin. This won't be exact but should get you started.
PHP
Code
..... pnRender instanstiation snipped.....
$users = pnUserGetAll();
$useritems = array();
foreach ($users as $user) {
$useritems[$user['email']) = $user['uname']'
}
$pnRender->assign('useremails', $useritems);
return $pnRender-fetch('your _template.htm');
template
Code
..... rest of template snipped....
<select name="email">
<!--[html_options from=$useremails]-->
</select>
.... rest of template snipped....
-Mark
--
Visit My homepage and Zikula themes. -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 413
Ok so I took a look at the code above and am trying to debug on my side now and for the life of me I am not sure where I messed up at here is my code thus far:
Code
function pnChange_admin_new()
{
if (!pnSecAuthAction(0, 'pnChange::', '::', ACCESS_ADD)) {
return pnVarPrepHTMLDisplay(_MODULENOAUTH);
}
$pnRender =& new pnRender('pnChange');
$pnRender->caching = false;
if (pnUserLoggedIn()) {
$name = pnUserGetVar('uname');
$email = pnUserGetVar('email');
}
$users = pnUserGetAll();
$useritems = array();
foreach ($users as $user ) {
$useritems($user['email']) = $user['uname']'
}
$pnRender->Assign('name', $name);
$pnRender->Assign('email', $email);
$pnRender->Assign('usermails', $useritems);
// return $pnRender->fetch('pnChange_admin_new.htm');
return $pnRender->fetch('pnChange_test_java.htm');
}
And the error I produce is:
Code
Parse error: parse error, unexpected '=' in /var/www/noc/htdocs/modules/pnChange/pnadmin.php on line 32
What have I done incorrectly here??
Thanks
-SUNADMN -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
As with any parse error you have a syntax error on (or before) that line.
-Mark
--
Visit My homepage and Zikula themes. -
- Rank: Developer
- Registered: Jun 16, 2003
- Last visit: May 29, 2010
- Posts: 1966
$useritems($user['email']) = $user['uname']'
missing closing semicolon ^^^ -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 413
Nope that's not it either I have chenged everything I can think of to make this work:
Code
foreach ($users as $user ) {
$useritems($user['email']) = $user['uname']';
}
foreach ($users as $user ) {
$useritems($user['email']) = $user['uname'];
}
foreach ($users as $user) {
$useritems[$user['email']) = $user['uname']'
}
foreach ($users as $user) {
$useritems[$user['email']) = $user['uname']';
}
none of the above work and still I can't hunt down the issue ( I have deleted the code that has the foreach loop and things run ok, I do not get errors ).
I am lost as to what I could be missing... is it pointing me right in the face and I just dont see it???
Thanks all
-SUNADMN -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
You need to pay closer attention to the syntax your code ;) - check the number of square brackets on the left hand side of each of the array element assignments.
-Mark
--
Visit My homepage and Zikula themes. -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Feb 14, 2006
- Posts: 33
I do my editing in SciTE, and it makes this sort of thing easy to spot. You can tweak the syntax highlighting in a stylesheet to focus on the things that cause the most grief. For me it's deeply nested ().
- Moderated by:
- Support
