If you cannot control the order of args,  you could still look for an int,  
but that may not always be reliable.  I sometimes decide to use vars 
instead.  Then you know exactly what you have:  your/url/here?id=1234
Construction of the url is easy using the URL helper.

On Friday, November 16, 2012 12:45:35 PM UTC, Mike H wrote:
>
> I am using smartgrid for the membership database I am building.
>
> I have 3 tables, contact (the members contact details and name), courses 
> (any courses the member is doing with us) and membership (the users 
> membership details).
>
> I am using conditionals to present customised view of the generated forms 
> tables and records, basically a little dashboard that will sit above the 
> contact/member/course details giving an overview of that contact. However I 
> am struggling to extract the row id for the contact in order to pull up 
> data for my dashboard.
>
> The following is the URL I get when viewing a contact with the id 11: 
> 27.0.01:8000/MYDB/default/contact_manage/t_contact/t_membership.f_contact_id/11/view/t_membership/11
>
> On this particular url I can get the id using:
> request.args(2)
>
> However the postion of the id is not the same on every page  for example 
> when I view another contact (12) I get this URL:
>
> http://127.0.01:8000/ILSPA_DB2/default/contact_manage/t_contact/view/t_contact/12
>
> The argument with the position 2 is t_contact not 12.
>
> Is there some voodoo I can use to get the id of the entry in order to use 
> it to pull up data from other tables?
>
> FYI I have included a snippet from the controller and corresponding view.
>
> Controller code:
>
> @auth.requires_login()
> def contact_manage():
>     memberId = request.args(2)
>     form = SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses',
> 't_membership','t_paypal'], onupdate=auth.archive, formname="Contact 
> Manager")
>     return locals()
>
> View Code:
>
> {{extend 'layout.html'}}
>
> {{if 'view' in request.args:}}
> <p>Do something with {{=memberId}}</p>
> <h2>Manage Contact</h2><p>{{=form}}</p>
> {{else:}}
> <h2>Manage Contact</h2><p>{{=form}}</p>
> {{pass}}
>
> Thanks in advance.
>
> Mike
>

-- 



Reply via email to