Locomotive CMS Detect and Display Views for Mobile - mobile

I have a LocomotiveCMS site up and running on Heroku. I can edit my templates locally and push using Wagon. It works great!
However, I'd like to be able to serve a separate set of views for mobile devices (phones really) vs desktop/tablet. Can it be done easily? Will it require large modifications to the engine?
EDIT: I should add that I have done this before for a basic Rails app with no issues. I know how to detect a mobile device by examining the user agent and creating a separate folder (such as views_mobile) to store the mobile views. Would like to be able to do the same for LocomotiveCMS

That's a tough question. For the next version of LocomotiveCMS (v3), we'll use a full stack of middleware so that it will be easy to add your own custom behaviors.
But, for the current version of the engine, it's not that easy. However, I'm thinking about something. Perhaps you could create a Route constraint for the mobile detection (http://guides.rubyonrails.org/routing.html#advanced-constraints).
Then, you would modify your routes.rb by adding this:
match '*path' => 'locomotive/public/pages#show', page_path: 'mobile-index', constraint: MobileContraint.new
Never tested so it might not work :-) Happy patching!
Didier

Related

What is the best way to integrate a small angular.js application into Wordpress?

I am working on adding a small one-page AngularJS application to my friend's Wordpress site. The application will take some user input and generate on-screen output using that input. It will also log the user input for analysis purposes.
I will need to be able to host the files for that page on my friend's site as well as create a back-end script that can capture the user input and store it to a MySQL database.
I have worked with WordPress sites before but have never customized them or written a plugin. How would you go about making this happen?
I will select the answer that leads me down the most efficient / effective path. Thanks!
After poking around for a while, I ran across the Advanced Custom Fields plugin. Using this helped me add custom JavaScript to the specific page that needed Angular support.
Here is information on how to use ACF to add JavaScript support:
https://www.godaddy.com/garage/3-ways-to-insert-javascript-into-wordpress-pages-or-posts/
Here is the plugin itself:
https://wordpress.org/plugins/advanced-custom-fields/

Integrating mobile app and mobile web

Currently I am developing an app in corona sdk. It is still very early in the development stage so I can change the IDE or SDK if needed to achieve my goal.
I wish to create an app that can be played on multiple platforms(mainly ios and android) and I eventually want the users to be able to use the browser to continue playing at home with their progress saved. It is a simple app and could probably be recreated in html. They will have to login their accounts in order to play
How do i go about to achieve this? Should I complete my app in corona first, and then recreate the app in html and php and link the database to it separately or is there a specific development kit I could use that has this ability. Also, I am new to the development scene, how do I detect if the user is logged in a particular platform as I realize if they are logged in, in multiple places and give multiple entries it may cause problems.
If you are new to the development scene then you should continue developing with Corona.
Corona doesn't povide any web port but I know Unity does.
I think first you should complete your game for mobile platforms and if it will have success you can port it to web.
You can read this:
http://www.graphic-buffet.com/2012/06/indie-game-development-where-start/
You might want to try phonegap (http://phonegap.com/). I have never used it, I just know that it exists, so do some research to see if it would be a good fit. This might allow you to create the app once for both browsers and mobile.

Reuse model and store from ExtJS in Sencha Touch

I already have an ExtJS app but now I'm trying to build a mobile version with Sencha Touch. I want the browser to detect if it's running on mobile or not. That works fine, but what is my next step?
I have it redirected to a /mobile folder with a new index.html and that works fine until I try to reach classes from a parent class.
Is it possible to load the mobile app.js instead of the extjs app.js in the primary index.html?
I don't think you will be able to get away with having just one application. Ultimately you would need to create two different apps - one using ExtJs framework, another using Sencha Touch.
Whether you will be able to share some code is a good question. I think you should be able to share models, but that's about it. And even though - I would not recommend doing that either. Because even if show similar information from the same back end in both full and mobile version of your application, you might not need all of it in the mobile application. And if you don't need all of it - your models will be different.

Setting up a multilingual wordpress site

I am trying to set up a multilingual site using wordpress. I went through http://codex.wordpress.org/Multilingual_WordPress#Plugins_that_direct_you_to_external_translation_services and decided to use this option Plugins like Multisite Language Switcher and the newcomer Multilingual Press link together separate WordPress network (multisite) installations for each language by pinging back and forth..
Now i installed the Multilingual press and set up a network. The url of my site was wordpress.private.net and next on is it.wordpress.private.net. Both the domains are served from same folder. But still when i visit the it.__ site it shows in english language and that too without all the posts.
I get this error on network dashboard
You didn't setup any blog relationships! You have to setup them first to use Multilingual Press. For this, go to Network » Sites » and choose a blog to edit. Then go to the tab "Multilingiual Press" and set up the relationships.
But there is no option to set up the relationships in the tab "Multilingiual Press. Please guide me where am i going wrong?
Any other way to set up is also welcome.
My main moto is to run my wordpress site in two languages
I'm also developing a website in two languages.
I haven't used what you are using, so I cannot help you in that regard.
For my project I installed qTranslate plugin and I haven't had any problems with it so far.
In the plugin settings you specify language you want to use and other settings like how the language will appear in URL (?lang=en , /en/ in front of URL , http://en.yoursite.com)
When you edit post or page, you will have additional tab in the editor, one for each language, so it is really easy to use it.
It also supports qTranslate Services, that ables you to use professional human translation services with a few clicks, but I haven't used that yet.
A general note:
Do NOT auto translate your pages with Google Translate. This is basically spamming the google index.
If you want to autotranslate your page, use the google translate widget.
You can read that somewhere in the google guidelines too.
About your plugins:
qTranslate is fine and simple. But it does store all translations into one post. So if you later decide to change to a different plugin, you are toast.
I've heard about Multilingual, but I think it might still be a bit unstable.
The most commonly used is WPML. Might not be the best and it's not free. But it works and I have many clients that use it happily.
But again, DON'T auto translate your page. It's useless and will get you down ranked.

Prompt user to install/view app on mobile site

Does there exist some kind of plugin or lightweight method of determining whether
A. A user is using a mobile device
B. The user has a particular app
C. The user does not have a particular app.
And depending on what criteria the user satisfies, display a prompt (modal, overlay, pop-up) that allows the user to view the app (if installed) or to install it (if they do not have it installed).
I realize "A" can be achieved by using media queries but I am not sure how to configure the others.
I've seen this done on many many sites so I know that it is not uncommon (view screenshot). Ideally I just want to implement some quick solution. I'm looking for something similar to "Hello Bar" for mobile only, I suppose.
Any help will be appreciated.
Example: http://i.imgur.com/VkWKu.png (the prompt at the top of the browser)
I ended up finding this:
http://developer.apple.com/library/ios/#documentation/AppleApplications/Reference/SafariWebContent/PromotingAppswithAppBanners/PromotingAppswithAppBanners.html
Which is exactly what I was looking for and will work in tandem with the other solutions.
I would try this approach if you really need to know if a user has your app installed.
When your app is installed and first run have it create a cookie. The only thing you have to remember to use is the CookieSyncManager because the set Cookies are stored in RAM and not storage, CookieSyncManager will sync these two.
CookieSyncManager.createInstance(context)
CookieSyncManager.getInstance().sync()
Once you've set the cookie you can then read the Cookie with the website, if its there show popup etc. Oh and only show this popup only if its a mobile device: http://www.quirksmode.org/js/detect.html
Android Developer On CookieSyncManager: http://developer.android.com/reference/android/webkit/CookieSyncManager.html
Bolg Post Explaining the Usage of the CookieSyncManager:
http://blog.tacticalnuclearstrike.com/2010/05/using-cookiesyncmanager/
I know how to do this with android not iOS or Windows...
There's no standard way to do this.
See the end of this post: http://blogs.msdn.com/b/ieinternals/archive/2011/07/14/url-protocols-application-protocols-and-asynchronous-pluggable-protocols-oh-my.aspx for one mechanism available to JavaScript in IE10.
IE10's Metro environment offers this: http://blogs.msdn.com/b/ie/archive/2011/10/20/connect-your-web-site-to-your-windows-8-app.aspx but I don't think that exists for the mobile browser.

Resources