In the above controller, you refers to the variable request.vars.category,
which refers to a POST or GET variable named "category"
So in your link you should have the same variable:
{{=A("recipes",_href=URL('recipes',vars=dict(*category*=<category><http://category.id>
)))}}
You then replace <category> with a known category id.
Le mercredi 30 mai 2012 16:23:37 UTC+2, BlueShadow a écrit :
>
> Hi I think I took this code from one of massimos tutorial videos:
>
> def recipes():
> try:
> failtrial=int(request.vars.category)
> rows=db(db.recipes.category==request.vars.category).select(orderby
> =~db.recipes.submitted)
> except:
> rows=db().select(db.recipes.ALL, orderby=~db.recipes.submitted)
>
>
> form=SQLFORM(db.recipes,fields=['category'])
> return dict(form=form,recipes=rows)
>
>
>
> It displays (with the view file of course) a list of all recipes and a
> form where you can choose a category if you choose one it desplays only the
> ones from that category.
> I tried to modify it a little I like to add the functionallity to display
> all recipes from a category but get there with a link.
> I thought this would be pretty easy just
> use this line: {{=A("recipes",_href=URL(r=request,f='recipes',vars=dict(id=
> category.id)))}}
> but of course this doesn't work I tried a second try except block with id=
> request.vars.id
> but that messes all up.
> Thanks for your help guys
>