Hi David,
I'm really trying to add new features, and I'm working on a mobile version of my price comparison site. I've made a few easy changes and I'm almost there. I changed the search.php to searchmobi.php and call that when the user submits the search. I then created a searchresultsmobi.php to display the search results in a simple format. I've been able to strip off all but the image, product name (with link to product) and the price. These all show up in the search results. I'm stuck after the user clicks on the product name link and goes to the product page. I don't know how to adjust the products.php file and the html/product.php files to make this work. I go from the stripped down version, back to the full on website. Is there a way I can create a new productsmobi.php and html/productmobi.php can call those from the new searchresultsmobi.php?
Hi Lunen,
I've had a first go at creating a "mobile friendly" version of the default Price Tapestry theme - have a look at the following mobile version of the demo site in a mobile browser:
This is implemented almost entirely by a replacement /html/ folder. The only other change I have made is index.php to remove the home page search form which I have replaced by a search form in the header to appear on all pages.
There would be various ways to implement this. The simplest of course would be a dedicated installation running a mobile theme. Alternatively, one could modify the script files slightly to make the name of the HTML folder configurable, for example through the variable $config_htmlDirectory so that you might have:
/html/
/html.mobile/
...and then override the value from config.php to, say, "html.mobile" if the hostname is mobile.example.com, or even by auto-detection of a mobile browser.
I've posted the files as MobileHTML.zip to the Downloads page.
Cheers,
David.
--
PriceTapestry.com
David,
You've outdone yourself this time.
This is incredible. I'm working on getting it going now.
Thanks!
JT
Hi David.
Because my site would be a beast to recreate, I'll like to use the configurable html option. I don't think I need the index.php page because users are putting a query in on a mobile app and landing on the search results page. I've looked int he config.php file and the advanced one and I don't see the $config_htmlDirectory variable.
I don't mean to be a pain, but can you show me the code to do this?
Thanks again
Hi JT,
It's not an existing variable but something that can be added easily. Here's the steps for your default theme being served by www.example.com, and your mobile theme being served by mobile.example.com:
1) Edit config.advanced.php and add a new variable at the end of the file, just before the closing PHP tag:
$config_htmlDirectory = "html";
2) Perform a Search and Replace operation using your text editor on the following files:
brands.php
categories.php
index.php
merchants.php
products.php
reviews.php
search.php
SEARCH for:
"html
REPLACE with:
$config_htmlDirectory."
3) Upload your new mobile html theme to a folder called html.mobile
4) Edit includes/common.php and add the following new code at the end of the file, just before the closing PHP tag:
if (strpos($_SERVER["HTTP_HOST"],"mobile.")!==FALSE)
{
$config_htmlDirectory = "html.mobile";
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
It's almost there. On the mobile app i use
<form name='search' action='http://www.mysite.com/pathtopt/search.php'>
<input style="font-size:25px; color: #000" type='text' id='q' name='q' size='25' />
thanks
Hi JT,
If you've implemented /html/ folder selection as described above, if you can I would change your action URL to
http://mobile.mysite.com/pathtopt/search.php
That should do it!
Cheers,
David.
--
PriceTapestry.com
I did all the above, but now the http://mobile.mysite.com/pathtopt/search.php is giving a 400 error. Do I need to adjust the .htacess file?
Hi JT,
.htaccess isn't normally host specific (certainly the default .htaccess as in htaccess.txt in the distribution isn't), but it sounds more like your server isn't yet set-up to serve mobile.mysite.com as the same as www.mysite.com.
That would be where to look first - don't worry about the incoming requests in the first instance, but once http://mobile.mysite.com/pathtopt/ is serving the html.mobile version of your site the incoming queries should then work fine...
Also bear in mind that if you only recently set-up the mobile. subdomain of your mysite.com the DNS might not have yet propagated fully - it may be working on your desktop computer, but not yet resolvable by your mobile device - that could be all it is... you could check by going directly to mobile.mysite.com/pathtopt/ on your mobile browser and making sure that works...
Cheers,
David.
--
PriceTapestry.com
Hi david and those interest.
I set up the subdomain mobile.mysite.com, yet I'm still getting a URL not found when I use the action http://mobile.mysite.com/pathtopt/search.php from the mobile app. I don't want to reinstall everything on the subdomain. I tried a redirect from the subdomain back to the main domain but that didn't work because the mobile html files didn't show up because it was coming through the main domain.
I was given this for the .htaccess file from my host
RewriteEngine
RewriteBase /
RewriteCond %{HTTP_HOST} mobile.mysite.com
RewriteCond %{REQUEST_URI} !^/compare_deals
RewriteRule ^(.*)$ site1/$1 [L]
I'm still stuck sorry. I don't know how to add this correctly into the .htaccess file. I've tried leaving out the first two lines of code but no luck.
Hi Lunen,
I changed your URL in the .htaccess text, but I tried your mobile.mysite.com and it was not working, I tried:
mobile.mysite.com (403 - Forbidden)
and
mobile.mysite.com/pathtopt/ (404 - Not Found)
...so the mobile. subdomain still isn't working properly as far as I can see. Don't worry about the action from your mobile app until mobile.mysite.com is working - that's the first step.
Can you check with your host why
mobile.mysite.com
and
www.mysite.com
are not yet the same?
Cheers,
David.
--
PriceTapestry.com
I can't create an alias that points to a folder other than the websites root. My PT files are in a folder in the main directory, so I was told I had to create a new index.php file in my subdomain folder that redirects back to my PTsubfolder on the main domain. so here's the simple code they gave me
<?php
header("Location: http://www.example.com/subdirectory");
?>
It does work for a redirect, but it doesn't help for the mobile app because the url request is coming in with the www. not the mobile. That's why I was hoping to redirect from the .htacess file. why do hosts make things so hard? any ideas?
Hi JT,
As I understand it, your situation is that you can only set up a sub-domain e.g.
mobile.mysite.com
...that points to a sub-directory of your main website, e.g.
www.mysite.com/mobile/
I'm afraid I can't immediately think of any way that either .htaccess or a PHP redirect can make that appear to be a clean alias of www.mysite.com but first thing tomorrow I'll try and set-up an equivalent scenario on my test server and see if I can make it work somehow.
An alternative of course would simply be to keep a duplicate copy of your main www Price Tapestry installation in the mobile/ folder - so you would have
mysite.com/pathtopt/
mysite.com/mobile/pathtopt/
...where /mobile/pathtopt/ contains an exact replica of /pathtopt/ but WITHOUT the /feeds/ or /admin/ folders. There's no reason why that shouldn't work; and if that looks like it would do the trick, just update the action='' attribute in your mobile app to mobile.mysite.com/pathtopt/ and you should be in business...
Cheers,
David.
--
PriceTapestry.com
Hi David,
I was able to get it to work by just aliasing the mobile.mysite.com to www.mysite.com on the server. I didn't need to make it so hard. There is a slight glitch. The search works fine, but once a product is clicked on only the product title and image show up, not the description, price and link to the merchant. I'm going to look into that now. any ideas?
Thanks a ton for your help! I think it's almost there: Here's a link to the app: {link saved}
Ok I got it figured out. I just added the product.php from the regular /html file and adjusted the image size and it's humming a long. Thanks again for your help. I'm sure more people will be looking for mobile options!
Spot-on - looks great JT!
Cheers,
David.
--
PriceTapestry.com
Hi everyone,
I have installed the script and its working fine, except when a user goes to search for a product, it ignores the /mobile/ html files and goes back to using the default browser files.
All the /mobile/index.php, /mobile/merchants.php/ etc files are there, but it keeps going back to using the default website when it can.
How do I stop this?
Cheers
Matt
Hi Matt,
Did you install the mobile version on a sub-domain (m.example.com) or have you used a sub-directory /mobile/ ?
If using a sub-directory, whilst all database settings etc. should be the same you will need to modify $config_baseHREF at line 6 of config.php as follows:
$config_baseHREF = "/mobile/";
Cheers,
David.
--
PriceTapestry.com
Hi David,
Its working, except for when I click on a product in mobile mode it comes up with:
"Not Found
The requested URL /mobile/products.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
but the file mobile/products.php is actually in the mobile folder...
Strange??
Hi Matt,
That sounds like clean URLs have been enabled in the /mobile/ installation using $config_useRewrite = TRUE: in config.php, but either .htaccess has not yet been created, or has been created but RewriteBase is still set to /.
Make sure that a copy of htaccess.txt has been saved in the /mobile/ folder, and in that file, make sure that line 5 has been replaced with:
RewriteBase /mobile/
That should be all it is!
Cheers,
David.
--
PriceTapestry.com
Hello Lunen,
I have actually been looking at this. I think the best way to go about it would be as much as possible to implement the mobile version of your price comparison site via a different set of /html/ files specifically designed for mobile viewing. It would be straight forward to modify the script slightly to pull in the appropriate set of /html/ files (by making the name of the html folder configurable) so that it can be dynamically chosen, either by host name or even auto-detection of a mobile browser.
As you're working on this now I'll get what I have in mind online this afternoon for you to have a look at - check back around 4PM, I should have it functional by then..
Cheers,
David.
--
PriceTapestry.com