On Friday, February 19, 2016 at 10:06:51 AM UTC-8, Ron Chatterjee wrote:
>
> Was looking in the book for an example and can't seem to find it.
>
> Want to do something very similar to this with tags (postgresql
> <http://careers.stackoverflow.com/jobs/tag/postgresql> java
> <http://careers.stackoverflow.com/jobs/tag/java> angularjs
> <http://careers.stackoverflow.com/jobs/tag/angularjs> sass
> <http://careers.stackoverflow.com/jobs/tag/sass> css
> <http://careers.stackoverflow.com/jobs/tag/css>)
>
>
> http://careers.stackoverflow.com/jobs/107630/software-engineer-nest-financial
>
> I want to create tags and have links to them using the urls.
>
> my model:
> hobby_str = ['baseball', 'basketball', 'tennis', 'football', 'soccar']
> db.define_table("Post",
> Field("Title", "string", label='Give it a Title*',
> requires=IS_NOT_EMPTY(),default=None),
> Field("body", "text", label='Say something',
> requires=IS_NOT_EMPTY(),default=None),
> Field('game',
> type='list:string',label='hobbies',requires=IS_IN_SET ((hobby_str),
> multiple=True),widget=lambda field, value:
> SQLFORM.widgets.multiple.widget(field, value, size=3, style='divs',
> label=True)),
> Field('schedule',comment = 'Check all that applies',
> requires=IS_EMPTY_OR(IS_IN_SET(('day','Night', 'weekend only','weekdays',
> 'excluding holidays'),multiple=True)),widget=lambda field, value:
> SQLFORM.widgets.checkboxes.widget(field, value, style='divs', label=True,
> _class='horizontal')),)
>
> control:
> def show_links():
> posts = []
> posts = db().select(db.Post.ALL)
> return locals()
>
> view:
> {{import numpy}}
>
> <table>
> <td><b>Title</b></td>
> <td><b>Game</b></td>
> <td><b>Schedule</b></td>
>
> {{for i in range(0,len(posts)):}}
> <tr>
> <td>{{=posts[i].Title}}</td>
> <td>{{=posts[i].game}}</td>
> <td>{{=posts[i].schedule}}</td>
> </tr>
> {{pass}}
> </table>
>
> All the fields that show up as football, baseball, excluding holidays. I
> want them to behave as tags and by clicking them user can see the post
> related to those events only. For example. If someone click on basketball,
> all the posts related to basketball (s) will be grouped and shown together.
> Any examples?
>
>
No, but isn't the key element doing the db query? It would be something
similar to this from the Simple Wiki example:
def search():
"""an ajax wiki search page"""
return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
_onkeyup="ajax('callback', ['keyword'], 'target');")),
target_div=DIV(_id='target'))
I think that when Massimo was last presenting in SoCal, he did a simple
tagging demonstration, so you might look to see if he has that in one of
the video examples, but now that you've done the star ratings, I think
you've got the tools you need.
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.