Hi, is it possible to have on the front page a dropdown menu showing all users of a postnuke website? And is it possible that it changes dinamically adding all new users?
If its of any help, I am using AutoTheme. Thanks!
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
DropDown menu
-
**unknown user**
- Rank: Helper
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 877
The AutoTheme module won't help, but you could do that with some fairly simple PHP code. What would be the purpose of the drop-down and what would happen if you selected a particular person? -
- Rank: Expert
- Registered: Mar 11, 2003
- Last visit: Oct 21, 2009
- Posts: 1104
Can I toss in my 2 cents?
Long drop down lists are a pain in the butt! If you have more than, say 50 users, I'd abandon this idea. Actually I'd abandon it anyway but, if you feel it's what you want to do, I recommend you keep it small.
Also, keep in mind that the more often you query your database the greater the overhead and the more sluggish* your site will feel.
Slugger
* no relation!
-
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
Dunno why the hell you would want this, but here you go:
Code
<?php
list($dbconn) = pnDBGetConn();
$pntable =& pnDBGetTables();
$column = &$pntable['users_column'];
$sql = "SELECT * FROM $pntable[users]";
$result =& $dbconn->Execute($sql);
echo '<form name="form1"><div><select name="menu1">';
while(!$result->EOF)
{
$name = $result->fields[2];
echo '<option>'.$name.'</option>';
$result->MoveNext();
}
echo '</select></div></form>';
?>
Just place this code anywhere in your theme - note it doesn't have permission checks so it will come up for all users (it is wasy to add permission checks to it if you need).
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
**unknown user**
- Rank: Freshman
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 55
Hi thanks all for reply, and for comments that are always accepted a lot!
Well the story is this. I am building a website where the only modules there are a diary and a PhotoGallery. So there isnt any content, just users can write diaries and write comments on others diary. Exactly like a kind of blogging system. Now, because users interact a lot with the other users, I would like to have a Handy user selector on each page which will bring you to the user page(i am using advprofile). Users are already 150, and I know that is not a good solution, but I havent found any better one. I would be glad if you can suggest me something different.
Thanks again for the answers! -
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
YOu should be able to modify the snippet I gave you to do this - you can bring up any of the fields from the users table with this snippet:
$name = $result->fields[2];
$userid = $result->fields[0];
etc, etc
now I am sure the advprofile must have a variable in the URL to define a unique user - it will just be a matter of finding this and adding the appropriate HTML / variables to the snippet I supplied.
OR if you feel you cannot do this or can't be bothered I can make it happen for $US30.00 - just send a detailed explaination of your requirements to info [at] webvida.com and $30 via www.paypal.com to sales [at] webvida.com
Thanks :)
Have fun !
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
**unknown user**
- Rank: Freshman
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 55
Thanks a lot and I am sorry, unfortunately i am really really poor at the moment.
A lot of time i would love to just pay and make other people do the job, but i am poor so i have to do all myself, and given that i am really crap in PHP as i have started now, i am really on a bad position.
So. If its possible without bothering. i have 2 question.
First. How do i set a value to be shown as default.
I know how to do in HTML but in PHP i dont know.
Second. The sintax to go to advprofile is like this:
module=advProfile&uname=
where username is exactly what is shown on the dropdown with the code you gave me.
I would really be glad if you could help me, and i wish that if i get into more troubles i would have the manney to make you do the job.
Thanks again! -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2243
In the default option tag you have a parameter "selected". For instance:
<option selected="selected">value</option>
You'd need some extra code if you're going to look for a specific value to make selected - an if to check for a certain value.
<select name="uname"> will get the value sent throught the form as uname, if that helps.
Frank
Frank</select> -
**unknown user**
- Rank: Freshman
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 55
So this is what i have done so far:
between the head tag:
Code
<script language="JavaScript"><!--
// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************
function goThere(form){
var linkList=form.selectThis.selectedIndex
if(!linkList==""){window.location.href=form.selectThis.options[linkList].value;}
}
//--></script>
and than after the body tag:
Code
<?php
list($dbconn) = pnDBGetConn();
$pntable =& pnDBGetTables();
$column = &$pntable['users_column'];
$sql = "SELECT * FROM $pntable[users] ORDER BY pn_uname";
$result =& $dbconn->Execute($sql);
echo '<form name="dropMenu"><div><select name="selectThis" onChange="goThere(this.form);">
<option selected value=""> Limoncelli</option>';
while(!$result->EOF)
{
$name = $result->fields[2];
echo '<option value="module=advProfile&uname='.$name'
">'.$name.'</option>';
$result->MoveNext();
}
echo '</select></div></form>';
But still doesnt workkkkkkkkk!!!!!!!!
Can anyone help me out please!!!!!!!!!
Thanks everyone for the answer submitted! -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2204
Code
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$column = &$pntable['users_column'];
$result = $dbconn->Execute("SELECT $column[uname] FROM $pntable[users] WHERE $column[uname]<>'".pnConfigGetVar('anonymous')."' ORDER BY $column[uname] ASC");
echo '<form name="uform">
<select name="umenu" onchange="location.href=uform.umenu.options[selectedIndex].value">';
for (; !$result->EOF; $result->MoveNext()) {
list($uname) = $result->fields;
echo '<option value="index.php?module=advProfile&uname='.$uname.'">'.$uname.'</option>';
}
echo '</select></form>'; -
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
I see you used a different DB connection type than me, IR actually if I recall properly I think it the method used in pn750 and later? I remember when I made a module I couldn't get this method doesn't work with pn726 , I think...
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2204
..right.. you'd just list the $dbconn variable in .726 and below... as you did above :) ..that works with .750+ as well, but there are performance advantages to using the method added in .750. -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2204
hi fracozzo..
you can add it above the "for" loop:
Code
echo '<form name="uform">
   <select name="umenu" onchange="location.href=uform.umenu.options[selectedIndex].value">';
echo '<option value="">- Select - </option>';
   for (; !$result->EOF; $result->MoveNext()) {
   list($uname) = $result->fields;
echo '<option value="index.php?module=advProfile&uname='.$uname.'">'.$uname.'</option>';
   }
echo '</select></form>';
..enjoy :)
- Moderated by:
- Support
Users on-line
- 0 users
This list is based on users active over the last 60 minutes.
