Pages

Friday, October 19, 2012

Posting code within editor


Integrate ckeditor with php pages

  1. Download the ckeditor.zip file
  2. Paste ckeditor.zip file on root directory of the site or you can paste it where the files are
  3. Extract the ckeditor.zip file
  4. Open the desired php page you want to integrate with ex: page1.php
  5. Add some javascript first below, this is to call elements of ckeditor and styling and css without this you will only a blank textarea
  6. 
    
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    
    
    
  7. Now, you need to call the work code of ckeditor on your page page1.php below is how you call it
  8. 
    
    <!--php
    // Make sure you are using a correct path here.
    include_once 'ckeditor/ckeditor.php';
    $ckeditor = new CKEditor();
    $ckeditor--->basePath = '/ckeditor/';
    $ckeditor->config['filebrowserBrowseUrl'] = '/ckfinder/ckfinder.html';
    $ckeditor->config['filebrowserImageBrowseUrl'] = '/ckfinder/ckfinder.html?type=Images';
    $ckeditor->config['filebrowserFlashBrowseUrl'] = '/ckfinder/ckfinder.html?type=Flash';
    $ckeditor->config['filebrowserUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
    $ckeditor->config['filebrowserImageUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
    $ckeditor->config['filebrowserFlashUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';
    $ckeditor->editor('CKEditor1');
    ?>
    
    
    
  9. What ever name you want, you can name to it ckeditor by changing the step 6 code last line
  10. 
    
    $ckeditor->editor('mycustomname');
    
    
    
  11. Open-up the page1.php, see it, use it, share it and Enjoy

Thursday, October 18, 2012

.htaccess file redirect

// this file must exist in the current server
RewriteCond %{REQUEST_URI} etab$ [NC]

// this file or path can be in a different server
RewriteRule (.*) AM335x_eTAB.php [NC,L]

Tuesday, October 9, 2012

Image path setting in php for file upload

  • Example: $path = realpath(dirname(__FILE__)).'/uploads/products/';
  • To find server root: $_SERVER['SERVER_NAME'];
  • To find server base path to current file directory: $path = $_SERVER['SERVER_NAME'].dirname($_SERVER['REQUEST_URI']);