{{extend 'layout.html'}}
<h1>Current Applications</h1>
<ul>
{{for application in applications:}}
{{=IMG(application.logo)}}
{{=LI(A(application.name, _href=URL(r=request, f="show",
args=application.id))) }}
{{=application.descn}}
{{pass}}
</ul>
On Mar 13, 12:57 pm, Matthew McNaughton <mamcnaugh...@gmail.com>
wrote:
> Greetings team,
Hi Matthew and welcome
> I'm fairly new to HTML and WEB2PY and I am having some problems with
> code below. I am trying to write a view that pulls information from a
> database, called applications, and displays it on the page.
> Specifically, I can't seem to find the syntax for the IMG HTML helper?
> Also if I wanted to resize the image to make sure it wasn't larger than
> a particular size how would I do this? Thank you all. I'm enjoying
> learning web2py
>
> {{extend 'layout.html'}}
> <h1>Current Applications</h1>
> <ul>
> {{for application in applications:}}
> {{=IMG(application.logo)}}
just like you would do in HTML but adding an underscore to the
attribute name:
{{=IMG(_src=application.logo)}}
assuming application.logo contains the URI
if not use the URL function to build it.
You could also specify width and height here but that is probably
better left to CSS.
Thanks for the quick response. The database holds the actual image not the URL?
On Mar 13, 2010 1:06 PM, "DenesL" <dene...@yahoo.ca> wrote:
On Mar 13, 12:57 pm, Matthew McNaughton <mamcnaugh...@gmail.com>
wrote:
> Greetings team,
Hi Matthew and welcome
> I'm fairly new to HTML and WEB2PY and I am having some problems with
> code below. I am trying to...
just like you would do in HTML but adding an underscore to the
attribute name:
{{=IMG(_src=application.logo)}}
assuming application.logo contains the URI
if not use the URL function to build it.
You could also specify width and height here but that is probably
better left to CSS.
> {{=LI(A(application.name, _href=URL(r=request, f="show",
> args=application.id))) }}
> {{=applica...
--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
On Mar 13, 1:15 pm, Matthew McNaughton <mamcnaugh...@gmail.com> wrote:
> Thanks for the quick response. The database holds the actual image not the
> URL?
Are you asking or telling?.
Without your model definition I can't tell, it all depends on how you
defined the logo field.
web2py helpers like IMG create the corresponding HTML element and
follow their syntax.
In HTML IMG has a required SRC attribute which specifies the location
of the image so that is what you have to provide.
apps.define_table('application',
Field('name', requires=IS_NOT_EMPTY()),
Field('category', requires=IS_IN_SET(['Accounting', 'Payroll',
'Inventory_Mngmnt', 'Office_Productivity', 'Email_Calendering',
'Human_Resource_Mgmnt', 'Business_Planning', 'Server Related', 'Content
Management'])),
Field('descn', 'text'),
Field('website'),
Field('logo', 'upload', requires=IS_IMAGE()))
apps.application.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(apps,
apps.application.name)]
your case will be:
<img src="{{=URL(r=request, f='download', args=application.logo)}}" />
take a look at web2py book, image blog section.
--
Kuba
--
Kuba
def download():
return response.download(request,apps)
On Mar 13, 6:31 pm, Kuba Kucharski <kuba.kuchar...@gmail.com> wrote:
> so..
> =IMG(_src=URL(r=request, f='download'...
>
> --
> Kuba
>
> On Sun, Mar 14, 2010 at 12:20 AM, Kuba Kucharski
>