equipment is the table.
the equipment details page is 'show' or 'details'. In reality, I thought I 
could get away with the default 'view' from sqlform.grid, using a 
slug...but it appears I cannot, so I have to create a custom 'show' or 
'details' page. If I do 
    links = [lambda row: A('Details',_href=URL('show','show', 
args=[row.slug]))]

i get a key error.
show and show being the html page and the controller...
 
 My apologize in advanced if I am making this more confusing than it needs 
to be. The help truly is greatly appreciated. I am essentially moving my 
whole entire online business on to web2py from an old modified shopping 
cart...so far I have the minimal but it way better and more simple using 
web2py


On Wednesday, August 22, 2012 11:25:24 PM UTC-6, Anthony wrote:
>
> The only argument to your lambda is "row", so I assume you want row.slug. 
> Because "equipment" is not an argument of the lambda, it will look for it 
> in the outer scope. It looks like you must have a function named 
> "equipment", which is what is being referenced in the lambda.
>
> Anthony
>
> On Thursday, August 23, 2012 1:05:45 AM UTC-4, SeamusSeamus wrote:
>>
>> sorry, replace products with equipment. My bad. I renamed it since and am 
>> using equipment instead of 'products'. I have it set up now and it is 
>> taking me to the view, but I cannot get the sqlform.grid to show anything 
>> except row.id. 
>>
>> On Wednesday, August 22, 2012 11:01:36 PM UTC-6, Anthony wrote:
>>>
>>> What is "equipment"?
>>>
>>> On Thursday, August 23, 2012 12:53:10 AM UTC-4, SeamusSeamus wrote:
>>>>
>>>> In my SQLForm.grid I added this
>>>>     links = [lambda row: A('Details',_href=URL('default','show', 
>>>> args=[equipment.slug]))]
>>>>     grid = SQLFORM.grid(query=query, links=links)
>>>>
>>>>
>>>> I also added the is_slug into the model...but get this error..
>>>>
>>>>     links = [lambda row: A('Details',_href=URL('equipment','show', 
>>>> args=equipment.slug))]
>>>> AttributeError: 'function' object has no attribute 'slug'
>>>>
>>>>
>>>>
>>>> On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:
>>>>>
>>>>> You want to create a slug?
>>>>>
>>>>> web2py comes with IS_SLUG validator which helps with this.
>>>>>
>>>>> db.define_table("product",
>>>>>     Field("title", unique=True),
>>>>>     ...
>>>>>     ...
>>>>>     Field("slug", compute=lambda row: IS_SLUG()(row.title)[0]
>>>>> )
>>>>>
>>>>> So now you can use slug field to build your urls.
>>>>>
>>>>>  URL("product", "show", args=product.slug)
>>>>>
>>>>> in product/show/product-name
>>>>>
>>>>> def show():
>>>>>     try:
>>>>>         product = db.product[int(request.args(0))]
>>>>>     except:
>>>>>         product = db(db.product.slug == 
>>>>> request.args(0)).select().first()
>>>>>    return product
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus 
>>>>> <morrisjam...@gmail.com>wrote:
>>>>>
>>>>>> I didnt mean to do {{ }}, but I mean domain.com/product/productname   
>>>>>> (Product name being the name of the variable in the field from the model)
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:
>>>>>>>
>>>>>>> What is {{fieldname title}}? How do you get that value?
>>>>>>>
>>>>>>> On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:
>>>>>>>>
>>>>>>>> Thanks, what about URLs so it is www.domain.com/product/{{**
>>>>>>>> fieldname <http://www.domain.com/product/%7B%7Bfieldname> title}}
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:
>>>>>>>>>
>>>>>>>>> You can set response.title and response.meta in the controller or 
>>>>>>>>> function to make it specific to particular controllers or functions 
>>>>>>>>> (or you 
>>>>>>>>> can set them conditionally in a model file). If you need to use a 
>>>>>>>>> database 
>>>>>>>>> value, just do a query to get the value (your probably want to cache 
>>>>>>>>> it to 
>>>>>>>>> improve performance).
>>>>>>>>>
>>>>>>>>> Anthony
>>>>>>>>>
>>>>>>>>> On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 1. What is the easiest way to make it so each page has it's own 
>>>>>>>>>> title? Currently it is set by layout.html, but what if I want its 
>>>>>>>>>> own page 
>>>>>>>>>> to have an independent title? 
>>>>>>>>>> 2. How can I make it so the <title> of the page is the "name" of 
>>>>>>>>>> a field in a model? I am using SQLForm now, and have /product/1 and 
>>>>>>>>>> would 
>>>>>>>>>> like to have /product/purple-desk
>>>>>>>>>> 3. How can I make it so the meta description on each page has its 
>>>>>>>>>> own ? For example, the description is the data in the field 'product 
>>>>>>>>>> description' used in the model.
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>>  -- 
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>>
>>>>>
>>>>>

-- 



Reply via email to