Nowadays, when the Internet is sweeping across the country, companies are increasingly creating their own websites. Almost everyone has information about prices for products, services, etc., in other words, prices. Often the price lists are immediately placed in the html page or a link to download them is given. In the first case, it’s good if the site has a CMS installed and you can edit pages, and if not? In the second, you need to download a price list on ftp. Both cases can be a stumbling block when updating the price list on the site if there is no own webmaster. Yes, and copying information from the finished price to the site, can lead to inaccuracies and errors, especially if the price is not small. And this is fraught with the loss of customers. Consider how to simplify the placement of prices online. At once I will make a reservation that I will not consider powerful systems where the CMS of the site interacts with the company's accounting department.
Many people know that there is a convenient service for posting and editing documents - Google Docs. It allows you to work with electrons tables, and most of the prices presented in this format. Why not place your main price list in Google Docs and not give a link from your site to view it, or even embed the display code into the page.
What is convenient:
- You can edit the document from any place where there is Internet.
- You can download the document in Excel format or print it immediately. Those. virtually no need to store it locally.
- You can give the right to edit the document only to certain people (director, accountant, etc.), the rest of it is available only by reading.
- If necessary, the document can be easily updated by exporting goods and prices from an accounting program in Excel format, and then importing it into Google Docs.
- The document on the site is always shown up to date.
Place the document on Google Docs.
Option One - Embed the code to display the document in your page
- Publish the document as HTML for embedding in the page.
- Paste embed code into your page.
- Look what happened
But what to do if you want to make a display of the price list in the style of the site design?
')
Option two - output the document using PHP
Google Docs has the ability to publish a document in CSV format (comma-delimited cells in a spreadsheet). PHP has the CSV parsing function fgetcsv (it worked incorrectly for me with the Russian text, I had to connect a third-party CSV parsing class).
- Publish the document as CSV.
- Download, parse and display the document on your page using a PHP script.
- We look what happened.
The problem may arise if allow_url_fopen is prohibited on the hosting where the site is located, i.e. There is no possibility to open the file by URL from Google Docs.
Option three - the output of the document using javascript
There is a wonderful service from Yahoo - YQL (Yahoo Query Language). YQL - SQL is a similar query language like SELECT, more
here , but
here you can see it in action. And the result can be obtained in json format and output using javascript.
- Publish the document as CSV.
- We build the query , in the query field, enter
select * from csv where url='https://spreadsheets.google.com/pub?hl=ru&hl=ru&key=0AlqBgmTjbqUpdEdtWkJpVEE4Mkt5XzhYWmluZjdoclE&output=csv' and columns='col1,col2,col3'
json and click “test”, if everything is correct, then our document will be displayed. And at the bottom of the page will be the URL of the request for use in your script. - We write javascript to parse and display the document.
- We look what happened.
The downside of this method is the inaccessibility of the text of the document for indexing by search engines. The advantages include reducing the load on the hosting, because The document downloads and parses the user's computer.
Source code examples of implementation
here and
here .