Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Redirect for alternate/mobile site version
I'm working on a mobile add-on that uses a mirror domain to show an alternative version of a vanilla site. On page load all links are converted to the mobile version if you are viewing from the mobile domain. It works great except that when you post a discussion or comment it redirects back to the non-mobile version after saving the comment.
The site urls look something like:
http://mysite.com/...
http://mobile.mysite.com/...
It seems to be going bad in the Redirect function in Framework.Functions.php, but I can't tell at what point the url is getting converted back to non-mobile. Anyone have any suggestions on what a possible workaround might be?
Thanks.
0
This discussion has been closed.
Comments
This might be more advanced than you'd like, but in essence what you want to do is make your configuration file a little more dynamic. Depending on the how the configuration file is requested, you could set the BASE_URL accordingly.
Basically, in your
conf/settings.php
file:if (strpos($_SERVER['HTTP_HOST'], 'mobile') !== false) $Configuration['BASE_URL'] = 'http://mobile.mysite.com/'; else $Configuration['BASE_URL'] = 'http://mysite.com/';
The variable you use to detect the mobile version may differ, but that's probably the best and easiest way to do it. All URLs in Vanilla are based on the BASE_URL config variable, hence the "BASE" part
I was setting BASE_URL to the mobile url inside of my mobile class, which wasn't working. I moved it outside the class and it now works.
Like:
if (substr_count('http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'],$Context->Configuration['MOBILE_URL'])) { $Context->Configuration['BASE_URL'] = $Context->Configuration['MOBILE_URL']; $MobileAlternative = $Context->ObjectFactory->NewContextObject($Context, "MobileAlternative"); $Page->AddRenderControl($MobileAlternative, $Configuration['CONTROL_POSITION_PAGE_END'] + 1); }
Another question, is it better to set $Context->Configuration['MOBILE_URL'] inside my extension, or should it be added to the conf/settings.php file? I'm not clear on if there is a standard protocol.