I have this fancy little help from you guys... But I can't quite seem to
work with the data the way I like.
Basically, I want to display a list of all users that have similar tags
that I do.  So I would get something like this:
Tag Name 1
 -- Massimo
 -- Jukka
 -- Billy
Tag Name 2
 -- Massimo
 -- Jukka
Tag Name 3
 -- Billy

It's for a tag cloud I am making.
This is the function:
----
def status():
    current_user_id=auth.user.id
    tags = db((db.users.id==db.user_tags.user_id)
        &(db.user_tags.tag_id==db.tag.id)
        &(db.user_tags.tag_id.belongs(
        db(db.user_tags.user_id==current_user_id)._select(
        db.user_tags.tag_id)))).select(
        db.users.ALL,db.tag.ALL,groupby=db.users.id)
    #Find all the users and put their tags into a list.
    singleTag = {}
    for tag in tags:
        if singleTag.has_key(tag.tag.id):
            singleTag[db(db.tag.id==tag.tag.id).select()].append(tag)
        else:
            singleTag[db(db.tag.id==tag.tag.id).select()] = [tag]
    response.title = "Your Profile Page"
    userForm = SQLFORM(db.users)
    if userForm.accepts(request.vars):
        response.flash='User Added!'
    elif userForm.errors: response.flash='Hmm... Something is wrong
here...'
    return dict(tags= tags, userForm = userForm, today=today, user =
auth.user, singleTag=singleTag)
----
And the view:
            {{for interests in singleTag.keys():}}
                {{for interest in interests:}}
                    {{=interest.name}}
                    <br/>
                    {{pass}}
                    {{for user in singleTag[interests]:}}
                        {{=user.users.first_name}}<br/>
                        {{pass}}
            {{pass}}
That get's me close...
As you may notice, I like programming more than databases. :P  But I
prolly should learn more about those db's :D
Any ideas?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to