Contact form 7 is a very powerful wordpress plugin that helps to develop easily web forms using shortcodes. It has also some addons to extend the functionalities. One I’ve found useful is Contact Form 7 Get and Show Parameter from URL plugin. It retrieves Get parameters from the URL and they can be used in the form and in the email sent after form submission.
Use [getparam parameter] to retrieve the GET parameters then use [showparam parameter] in the form body to show the input parameter. Use [parameter] in the email to pass the value after the form submission.
Reading the Magento API Rest guide, it indicates the standard path at: http://magentohost/api/rest. Unfortunately, I was not able to found it and it returns me the 404 error. Searching a bit in the forum, the solution was simple. The .htaccess file was not present in the website root. I installed the Magento website using the Plesk panel, so I think that was the problem, but I don’t understand why Plesk version does not provide the .htaccess file.
I’ve uploaded the standard .htaccess file from the downloaded Magento CE and problem was fixed.
While global variables should not be used in smart programming tecnique, I find them useful in RIA applications with Ajax requests.
Getting a random row from MySQL database is quite simple:
ORDER BY RAND()
Modifying the limit parameter I can get different random rows.
This query has a bit overhead so it could be used for few results less than 1000 rows.
In order to use the ajax function to retrive datas from another domain, you must use the Jsonp format togheter with a callback function in the GET header.
So the php code to convert an array to Json format becomes:
echo $_GET['callback'] . ‘(‘.json_encode($result).’)’;
The script will get the callback parameter from the requester and return correctly the Jsonp datas.
Whiteout it, the data is
blocked by browser, in order to prevent XSS attacks and so the responseText is empty while the Readystate is 4.