Yahoo! Developer Network Blog
« Previous | Main | Next »
November 24, 2009
Yahoo! Application Platform (YAP) search box code example
Putting a search box in your YAP app
Want to add a search box to your Yahoo application (YAP app)? Here’s some sample PHP code to help you get started. It consists of a single file that calls itself to perform a search and output the results. If the file is requested without a search_term parameter, it will output a form consisting of:
- yml:form tags defining a form that will make an asynchronous Get request when submitted. Because no param attribute is defined for the yml:form tag, it will call back to the application URL by default. The replace attribute specifies that output of the callback file will replace a DOM element in the app with the id matching the value of the attribute, which in this example is “results”.
- an input field and submit button
When the form submits back to this file with the search_term defined, the file outputs HTML for an unordered list containing the results of a search. This HTML is then placed on the page by the yml:form tag.
Prerequisites
- PHP 5.2
- A server that’s accessible to YAP, i.e., a server with a valid domain name and capable of receiving POST requests. For this example, I’ll assume the domain name is example.com.
- A YAP application. If you don’t have one already, you can create one using the YDN dashboard.
Usage
1. Put the code below into a file on your server. For this example, I’ll use the file name file.php.
2. In the YDN dashboard, set the Application URL to the location of the file you created in step 1, e.g., http://example.com/file.php.
3. Preview the app by clicking the Preview button in the dashboard.
4. In the app’s text field, enter a search term, e.g., “pizza”, and click the Search button.
5. View the search results when they appear below the text field.
Code
---
Erik Eldridge
Yahoo! Developer Network
Posted at November 24, 2009 6:37 PM | Permalink
Comments
I need a completeI idoit's guide on this subject. CAN somebody help me????
Posted by: Buzz young at December 12, 2009 3:08 PM
Hi Buzz,
The Yahoo! Application Platform (YAP) documentation has a nice "getting started" tutorial you may find helpful:
http://developer.yahoo.com/yap/guide/creating_open_app.html
You can ask technical questions on the YAP forums:
http://developer.yahoo.net/forum/index.php?showforum=40
Posted by: Erik at December 14, 2009 2:42 PM
@Robert
You can register a new app by clicking the "MY PROJECTS" link in the header above. If you're not signed in, you'll be redirected to a sign in page. If you don't have a Yahoo! account, you can create one from the sign in page.
Posted by: Erik at February 5, 2010 10:42 AM
i like it
Posted by: kathy lovenburg at February 8, 2010 1:39 PM
Post a comment
Comment Policy: We encourage comments and look forward to hearing from you. Please note that Yahoo! may, in our sole discretion, remove comments if they are off topic, inappropriate, or otherwise violate our Terms of Service. Fields marked with asterisk '*' are required.
Subscribe
Recent Blog Articles
view all
YQL Open Table for Google Buzz now live
Tue, 09 Feb 2010
INSERT INTO twitter.status ...
Mon, 08 Feb 2010
Announcing the Yahoo! Brasil Open Hack Day 2010, 20-21 March
Mon, 08 Feb 2010
Marketing hacks, linchpins, and tech women of valor
Sun, 07 Feb 2010
Yahoo! India invites you to join the first India Hadoop Summit
Thu, 04 Feb 2010
Recent Links
Appcelerator Titanium + Yahoo YQL on Vimeo
Mon, 08 Feb 2010
Tue, 02 Feb 2010
PhoneGap | Cross platform mobile framework
Sat, 30 Jan 2010
Web developers can rule the iPad - O'Reilly Radar
Sat, 30 Jan 2010
rc3.org - Is the iPad the harbinger of doom for personal computing?
Thu, 28 Jan 2010
Archives
2010
2009
2008
2007
2006
2005
Recent Readers

