Wednesday, 16 July 2014

Image not displaying uploaded by CKeditor

Uploaded Image Not uploading/Not showing can have might reasons:
  1. Upload image path is not correct.
  2. Tmp folder have not write permission to upload image. Because when have submit form after selecting image, It first move to tmp folder then to target folder.
  3. Image folder would not have enough permission.
  4. Image Path is not correct while getting image, also make sure image has been uploaded in target folder.
  5. Image is not accessible.



Uploaded Image not showing in Email
Problem: Whenever we upload any image through FCK editor. It start displaying in editor as well as in pages of our website.
Sometimes when we display all the content including image in our site it works fine. But when we send all the contents to email then all work except uploaded image (image was not displaying in email).
Reason behind this can that image have relative path.
Solution: Now for this, there should be absolute path in image source including www.example.com. So, that it work in our site as well as in emails.

for this just do the follow lines when uploading image through FCK-Editor.
1) open app/webroot/js/editor/filemanager/connectors/php/config.php
2) replace
Code:
$Config['UserFilesPath'] = '/app/webroot/files/'; 

$Config['UserFilesAbsolutePath']=''; 



WITH

Code:

$Config['UserFilesPath'] = "http://".$_SERVER['HTTP_HOST']."/app/webroot/files/"; 

$Config['UserFilesAbsolutePath'] = $_SERVER['DOCUMENT_ROOT']."/app/webroot/files/";



3) Clear the cache from

Code:

/app/tmp/cache/ 

/app/tmp/cache/persistent 

/app/tmp/cache/views

Above example are for cakephp, If you are using other framework/CMS then only path can be little different but reason will be same. Just understand the above all points of uploading image issue. then you will be able to overcome any type of issue regarding uploading through any Framework OR CMS.



Suggestion for SEO:
With use of text editor, we can upload multiple images/videos and set the attributes like alt tag, title tag in the photos/videos. These tags play very vital rote in SEO. If your photos videos have ALT tag, Title Tag then your website would have better ranking in Search Engines.


5 Best Related Posts are Following:1. PHP Technical Interview Questions and Answers for Fresher and Experienced
2. How to Add attribute in A Tag using jQuery
3. Wordpress Website title repeated two times in browser header [SOLVED]
4. How can I prevent SQL-injection in PHP [SOLVED]
5. Htaccess RewriteRule Flags by Code Example

Tuesday, 15 July 2014

Zend Framework Interview Questions and Answers

Question: What is a framework?
In software development, a framework is a defined structure in which we can developed a new project. Its better to developed in framework than in core technology Because when we get a easy setup and many inbuilt functionalities.


Question: What are the features of framework?
Feature of Framework An abstract design Set of common functionality inbuilt Fast & Reliable Already tested by 1000 of developers We can check the reviews & rating of framework before use


Question: How to get post/get variables?
getRequest();
$request->getParams(); //All Get Variables
$request->getPost();//all Post variables
$request->getParam('id','0'); //get Id variables

Question: What is Bootstrapping?
Many PHP applications funnel server requests into a single PHP source file (only php files) that sets up the environment and configuration for the application, manages sessions, manage translate and caching, and invokes the dispatcher for their MVC framework. They can do more, but their main job is to take care of the consistent needs of every page of a web application.


Question: What is Zend Engine?
Zend Engine is used internally by PHP as a complier and runtime engine. PHP Scripts are loaded into memory and compiled into Zend opcodes. this opcodes render the html files.


Question: How Zend Routing Works?
Zend_Controller_Router_Rewrite is the standard router for zend framework. Basically Routing is the process of taking a URI endpoint and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request. This values of the module, controller, action and other parameters are packaged into a Zend_Controller_Request_Http object which is then processed by Zend_Controller_Dispatcher_Standard. Routing occurs once, when the request is initially received and before the first controller is dispatched.


Question: What are Plugins in zend framework?
Plugins are triggered by front controller events,bookend each major process of the front controller and allow automating actions that apply globally.
routeStartup – before the current route is evaluated
routeShutdown – after the completion of routing
dispatchLoopStartup – before the dispatch loop is entered
preDispatch – before the current action is dispatched
postDispatch – after the current action is dispatched
dispatchLoopShutdown – after the dispatch loop is completed


Question: How to disable Layout?
$this->_helper->layout()->disableLayout();


Question: How to disable view files?
$this->_helper->viewRenderer->setNoRender(true);


Question: How to call two different views from same action?
$this->render('differentView.phtml');


Question: How to include css from controller and view in zend framework.
From View
$this->headLink()->appendStylesheet('filename.css')
From Controller
$this->view->headLink()->appendStylesheet('filename.css');


Question: What is FrontController?
It is based on Front Controller Design pattern. Zend also use singleton pattern.
routeStartup: This function is called before Zend_Controller_Front calls on the router to evaluate the request.
routeShutdown: This function is called after the router finishes routing the request.
dispatchLoopStartup: This is called before Zend_Controller_Front enters its dispatch loop.
preDispatch: called before an action is dispatched by the dispatcher.
postDispatch: is called after an action is dispatched by the dispatcher.