How to organize desktop and mobile views separately (Zend Framework) - php

I'm already running a desktop website with views and template files. Now I would like to develop a mobile version of my website.
I've already detect smart devices by using WURFL library within my own Plugin and I inject that plugin during application initialization.
I'm using Zend ContextSwitch Helper to change the context of current view file with suffix 'mobile' like: index.mobile.phtml.
What I need to organize my existing views under separate folder for mobile like: /views/mobile/index.phtml not as /views/index.mobile.phtml (same folder).
//Add Context
$this->addContext('html', array('suffix' => 'mobile'));
Please advise me how can I tell application to search mobile views under mobile for every views.
I'm using Zend Framework 1.12 version

Your desired approach may be confusing because /views/mobile/index.phtml will refer to "mobile" controller
You may override this by simply changing the template path destination for mobile templates. $view->setScriptPath('mobile')
Another way is to store them in the same folder but with different suffix /views/controller-name/action-name.mobile.phtml
You can achieve this just by changing the view extension using view renderer. $viewRenderer->setViewSuffix('mobile.phtml');
Or you may rewrite your templates using responsive webdesign :-)

Related

Symfony Mobile detect redirection different twig

I'm developing an application with Symfony now, i need to detect user support (desktop or mobile ) and redirect with the same controllers to different templates twig views (for desktop or for mobile).
I can't use media queries, for the HTML and CSS files, i have to different folders, one for desktop files and other for mobile files.
If you haven't found a solution for your application, have you looked at suncat/mobile-detect-bundle? It has both PHP and Twig hooks.

Yii2 How to reference the public main.php file on the server

I used yii2 framework to do three sites, the three sites belonging to different servers, their layouts / main.php exactly the same, how to make these three different domain name website share this main.php?For example, a company's community and forums, as well as the official website are exactly the same layout file, which means that the three sites of the header and footer is the
same, according to my current practice, the three sites are writing this layout File and inside the style and pictures, then the problem occurs, if you want to change the footer and the title html, css, js or pictures, there will be three sites together, this is too much trouble. My current idea is to put the main.php file into one of the site's root directory, and then three sites in the frontend / layouts / main.php reference to the main.php inside the code, but how to do pictures and Style, please Experts advise?
You can include remote files using the allow_url_include directive, but this is a really bad idea because of the security risks.
In my opinion the way to go is to build a module with your layout-related files and then update it in the applications, using composer (or any other tool) when you make changes.
You could use a scaffolding like advanced template where different application (eg: backend and frontend) share common code .. Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.
By default the advanced template includes three tiers: front end, back end, and console, each of which is a separate Yii application. front end and back end app share common namespace for models and config and you can extend for place a common layout or other application based on the same guidelines
This template is also designed to work in a team development environment. It supports deploying the application in different environments.
https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/README.md

Yii 2: Using a component only in backend

I have developed a component to crop images, and now I am migrating it to Yii 2.
There are a PHP class, a JS, a CSS, and an image files.
I am in doubt whether I place these files. Is it better to create a directory at basepath/vendor, or to add in the respective directories (image, css, and js), on backend/web and reference them in backend/assets/AppAsset? Note that I will only use this component in the backoffice.
What is the conventional way to do this?
For my experience is better build a component in vendor/yourVendorName/yourModuleName in the form of module and the you can use it where do you prefer adding to modules section of config/main.php of your app

Integrate a Zend application into Drupal 6 / 7

Given a "nacked" Zend application - is it possible to use the Drupal based layout and navigation?
What is the best way to integrate a Zend application into Drupal 6 / Drupal 7?
For Example:
User X visits my Drupal page.
He wants to use the Zend-Application called "Feedback".
This "Feedback" application should be able to use the layout of the Drupal page.
Everything but the outer layout would be written in PHP using Zend.
The module doesn't do Zend Framework app integration, it just allows you to use some of the ZF components (ie. Zend_Mail). I actually integrated a ZF app in Drupal 5, based on the Drake module (CakePHP integration).
It basically defines a Drupal menu with callbacks, these callbacks are passed to the ZF app (by including my zend bootstrap). Output of the ZF app is stored in a var (using the output buffering PHP functions), and I fetch the page title/js/css from the HTML, strip what isn't needed and then pass these back to Drupal (using drupal_set_title, drupal_add_js and drupal_set_html_head respectively). And yes, this is dirty, but it works for me...
Not sure this is quite what you want, but you can take out $application->run() from the Zend app's index.php and then include that file in any other application and have access to all of the resources of the Zend Framework and the Zend app itself.
Probably still quite involved to get it to do what you want though.
Joomla has a "wrapper" layout option which just shove some url into an iframe in the layout. I use this a a lot to glue standalone applications to a corporate intranet at work, we just have to tailor stylesheets to match.
It's a quick and dirty path but get you there fast and users really don't care.
I don't know drupal, but can't you simply include drupal files in your zend layout viewscript?

CakePHP Development of frontend/backend application

I have to develop frontend/backend application using cakephp.
can you give me advice how should i develop them, using same cakephp library?
or I have to develop them using separate cakephp libraries?
I am confused - cakePHP would be used to implement both.
PHP would be used to implement the server-side backend. The same "project" would also contain HTML, JS, CSS, etc that will be used to render the front-end within the browser. Any PHP "views" will also execute code on the back-end, although any HTML output will be rendered on the frontend.
Does that help at all? Or am I missing something?
If by frontend/backend, you mean an application with a user interface (frontend) and an administration interface (backend), then you want to refer to the Prefix Routing section of the manual. This will allow you to have separate flow and interfaces (controller/view) for each type of user while sharing the same data (models).
If by frontend/backend, you mean an application (frontend) that communicates with another server application (backend) using web services, then you want to look at the Additional Class Paths section of the manual. This will allow you to share common classes with two (or more) separate applications.
Note: the above links are for CakePHP 3.x, though these features have existed in one form or another since v1.2.
Not quite sure if I understood you correct, but if I did:
You can set up multiple projects using the same cake-core files. The core files don't even need to be placed in the webroot folder..
http://book.cakephp.org/view/35/Advanced-Installation
For your own sanity, you should regard the backend management as part of the same project as the frontend.
The systems I have built generally use view-type methods for the public view and crud-type methods for the admin view. How you lock down the admin is your choice. Personally I don't like the default admin prefix way. I use login and ACL - Mark Story's tutorial on http://book.cakephp.org/ is superb. With that you can password protect methods.
CakePHP is very flexible and extensible and you can make the administration as simple or as flexible as you like.

Categories