Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 10,760
» Latest member: zaidu92
» Forum threads: 67,397
» Forum posts: 421,516

Full Statistics

Latest Threads
Failing to connect to dat...
Forum: Installation & Setup
3 hours ago
» Replies: 0   » Views: 14
how to make shorten url i...
Forum: General Help
3 hours ago
» Replies: 4   » Views: 78
Need help related to my c...
Forum: Installation & Setup
4 hours ago
» Replies: 31   » Views: 1,551
Upload multiple files
Forum: Libraries & Helpers
6 hours ago
» Replies: 3   » Views: 176
Javascript/Html Server si...
Forum: General Help
9 hours ago
» Replies: 6   » Views: 100
Upgrading from 2.1.x to 3...
Forum: Installation & Setup
9 hours ago
» Replies: 3   » Views: 106
How to Count the number o...
Forum: General Help
9 hours ago
» Replies: 11   » Views: 229
PHP / jQuery Developer Ne...
Forum: Jobs
Today, 06:41 AM
» Replies: 11   » Views: 5,104
Codeigniter Bundle MMVC
Forum: Addins
Today, 12:20 AM
» Replies: 1   » Views: 1,089
CodeIgniter 3.1.7 Release...
Forum: News & Discussion
Today, 12:03 AM
» Replies: 28   » Views: 13,215

 
  Eventually CRACKED IT - Menu driven multiple CodeIgniter applications
Posted by: El Forum - 08-23-2007, 10:40 AM - Forum: Archived Development & Programming - Replies (22)

[eluser]John_Betong[/eluser]
Hi All,

Preamble

Delphi has a wonderful technique that allows the programmer to easily switch
between applications by using a menu system.

CodeIgniter's rigidity and hard-coding has been bothering me for quite some time
as to the easist way to achieve:
   1. easily switch CodeIgniter applications
   2. use a common codeIgniter System folder.

I used to manually edit my "index.php" file but now with a slight modification
to the file I can now select the application from "_menu.php".
 
 
Usage
I have the following application directories setup: each directory is copied
from CodeIgniter's system/application folder.

My Localhost directory structure

Code:
...
    ci_bandwidthmeter
    ci_betsprint
    ci_fred
    ci_jokes
    ci_plaroma
    ci_rentaroofbox
    ci_system // renamed CodeIgniter's "system" folder for consistency
    ...
    index.php // modified
    _menu.php //

 

The index.php was slightly modified so that instead of having
"$application_folder" hard-coded it now reads from an "_application.php" file.
I wrote a "_menu.php" file that generates the "_application.php" file.

index.php
Code:
...
  ...
  // old code that had to be manually edited  to select different applications
  // the required application was copied and pasted to be the last declaration
    $application_folder = 'ci_bandwidthmeter';
    $application_folder = 'ci_betsprint';
    $application_folder = 'ci_fred';
    $application_folder = 'ci_jokes';
    $application_folder = 'ci_plaroma';
    $application_folder = 'ci_rentaroofbox';
    
  // new _menu.php driven setting  
  include('_application.php'); // contents generated from "_menu.php"
  $application_folder = APPLICATION_FOLDER; // included contents from  "_application.php" file
  ...
  ...
 
_menu.php
Code:
<?php

  // file name to save CodeIgniter's $application_folder variable
  $filename = getcwd() .'/_application.php';  

  // delete file that holds the $application_folder variable if and only if it exists
  if (file_exists($filename)) {
    unlink($filename);
  }

  // check to see if a $application has been passed at the command line
  $application   = isset($_GET['application']) ? $_GET['application'] : ''; // '$application is NOT set' ;
  
  // write the $application variable to the $filename file
  if ($application) {
    $application   =  "<?php define('APPLICATION_FOLDER', $application) ?>";
    
    $saved  = file_put_contents($filename, $application);
    if ($saved) {
      header("Location: index.php"); /* Redirect browser */
      exit;
    }else{
      // echo 'Message goes here ==> '. $filename;
    }
  }//endif $application
    
  
  // optional to eliminate html errors
  if (file_exists('_head.php')) {
    include('_head.php');
  }else{
    echo '<html><title>My CodeIgiter menu</title></head>';
  }
    
  // fall through to menu selections using radio buttons
?>

<body style='background:#f00 none; color:#00f'>

  <div style='width:40%; margin:4em auto; background:#fff none; color:#000; border:outset 6px; padding:1em'>

    &lt;form action='_menu.php' style='font-size:1.4em'&gt;
      <dl>
        <dt style='color:#f00'>My CodeIgniter Applications<br /><br /></dt>
           &lt;?php
              $b = array(
                          /* 'system/application', */
                          /* 'plaroma-web-vhost/40c074f1c862da07d2a392dfdd89dd23',*/
                          'ci_bandwidthmeter',
                          'ci_betsprint',
                          'ci_fred',
                          'ci_jokes',      
                          'ci_plaroma',
                          'ci_rentaroofbox'
                        );  
      
              $ddstart = "<dd>&lt;input type='radio' name='application' value='" ; // ."'  /&gt;" ;
              foreach($b as $row):
                echo $ddstart . $row ."'  />$row</dd>";
              endforeach;  
           ?&gt;  
         <dt>
            <br />
            &lt;input type="submit" value="&nbsp;&nbsp;Continue&nbsp;&nbsp;" class='button' /&gt;
            <br />
         </dt>
        
        </dl>
    &lt;/form&gt;
  </div>
&lt;/body&gt;
&lt;/html&gt;
&nbsp;
I am curious to know if anyone else has done something similar?
&nbsp;
Cheers,
&nbsp;
John_Betong
&nbsp;
&nbsp;


  Installing / Integrate FCKEditor as form_helper extension.
Posted by: El Forum - 08-23-2007, 10:13 AM - Forum: Archived Development & Programming - Replies (39)

[eluser]flyer[/eluser]
Hi,

Thought someone might find this useful. Some of the other FCKEditor/CodeIgniter integrations seem to want to add it as a library or otherwise. The way I see it, its basically a fancy text area, and should be treated as such. Hence integration into the form helper.

It has 3 basic steps:

Step 1.

Download and unzip the FCKEditor application into a directory of your choice.
I prefer either the /system/plugins/fckeditor/ or /system/application/plugins/fckeditor/ or my choice - external/fckeditor/


Step 2.

Add following FCKEditor settings to the system/application/config/config.php file:

Code:
/*
|--------------------------------------------------------------------------
| FCKEditor Basepath
|--------------------------------------------------------------------------
|
| The path from your site's root in which the fckeditor folder is. Note
| this is from the site's root, not the file system root. Also note the
| required slashes at start and finish.
|
|    e.g. /fckeditor/ or /system/plugins/fckeditor/  etc...
|
*/
$config['fckeditor_basepath']    = "/system/plugins/fckeditor/";

/*
|--------------------------------------------------------------------------
| FCKEditor Toolbar Set Default
|--------------------------------------------------------------------------
|
| The default Toolbar set to be used for FCKEditor across your site. Leave
| as empty string or comment out if your happy enough with the standard
| default.
|
*/
$config['fckeditor_toolbarset_default'] = 'Default';

Step 3.

Finally the new helper class. The following code should be placed in a file named:
/system/application/helpers/form_helper.php
Note this will override /system/helpers/form_helper.php but all functions are imported from here anyway, so no clash or reduced functionality should occur.

Code:
&lt;!--****** FILE /system/application/helpers/form_helper.php code ********--&gt;

&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

include_once( BASEPATH . '/helpers/form_helper'.EXT);

function form_fckeditor($data = '', $value = '', $extra = '')
{
    $CI =& get_instance();

    $fckeditor_basepath = $CI->config->item('fckeditor_basepath');
    
    require_once( $_SERVER["DOCUMENT_ROOT"] . $fckeditor_basepath. 'fckeditor.php' );
    
    $instanceName = ( is_array($data) && isset($data['name'])  ) ? $data['name'] : $data;
    $fckeditor = new FCKeditor($instanceName);
    
    if( $fckeditor->IsCompatible() )
    {
        $fckeditor->Value = html_entity_decode($value);
        $fckeditor->BasePath = $fckeditor_basepath;
        if( $fckeditor_toolbarset = $CI->config->item('fckeditor_toolbarset_default'))
                $fckeditor->ToolbarSet = $fckeditor_toolbarset;
        
        if( is_array($data) )
        {
            if( isset($data['value']) )
                $fckeditor->Value = html_entity_decode($data['value']);
            if( isset($data['basepath']) )
                $fckeditor->BasePath = $data['basepath'];
            if( isset($data['toolbarset']) )
                $fckeditor->ToolbarSet = $data['toolbarset'];
            if( isset($data['width']) )
                $fckeditor->Width = $data['width'];
            if( isset($data['height']) )
                $fckeditor->Height = $data['height'];
        }
        
        
        return $fckeditor->CreateHtml();
    }
    else
    {
        return form_textarea( $data, $value, $extra );
    }
}

?&gt;

form_fckeditor() Usage

This function is identical in nearly all respects to the form_textarea() function above except that it generates a FCKEditor editor instead of a textarea and it takes some additional $data fields. So please read the Form Helper section of the Code Igniter User Guide!

However, the FCKEditor takes $data fields- 'name' 'basepath', 'toolbarset', 'width', 'height' which are passed on to the FCKEditor.php class from the FCKEditor application download. These $data fields control the settings for the editor, rather than any that you would normally pass to form_textarea() e.g. 'rows' or 'cols'.

Code:
***** USAGE ******

// e.g. 1
echo form_fckeditor('textareaName', $value );


// e.g. 2
$data = array(
              'name'        => 'textareaName2',
              'id'          => 'textareaName2',
              'toolbarset'  => 'Advanced',
              'basepath'    => '/fckeditor/',
              'width'       => '100%',
              'height'      => '200'
    );

echo form_fckeditor( $data );

It is important to know the regular $data fields that you would normal supply to the form_textarea() should also be provided if you wish to alter the defaults. This is because if the user's browser is not compatible with FCKEditor e.g. no javascript, the form_fckeditor() falls back to form_textarea().

Also, the 3rd parameter of the function, $extra, is discarded unless the function falls back to form_textarea().

Note that this helper technique requires zero modification of the FCKEditor source files, so when it comes to updates to FCKEditor, then your not going to have to remember where you've changed. Personally, I highly value keeping plugin code as independent as possible.

Any other changes to customize FCKEditor can be done exactly as per the FCKEditor documentation on its website.

Let me know what u think. Hopefully fairly easy to see what I've done!


Eddie

PS. Please don't ask about customizing FCKEditor. All customisation other than that above occurs within the FCKEditor source directory and better left for the FCKEditor support site Smile


  Porting ExpressionEngine to CI
Posted by: El Forum - 08-23-2007, 08:37 AM - Forum: Archived Development & Programming - Replies (9)

[eluser]zdknudsen[/eluser]
Okay so I needed a system similar to ExpressionEngine, when making sites for clients.

Currently I'm developing a community-driven website and I would like to use a CMS.

But since I do not need that many of EE's features and I had some additional needs I thought I would make it with CodeIgniter instead. Now I have a few questions regarding a port of EE to CI.

Am I allowed to create a templating system that parses like EE? (Modules = classes that can be used on templates, and modules similar to that of EE).

Can I use EE's database structure?

And basicly to what extend one can copy EE's features, seeing as EE is a commercial system.


  Image lib error
Posted by: El Forum - 08-23-2007, 08:07 AM - Forum: Archived General Discussion - Replies (2)

[eluser]emperius[/eluser]
In the settings i have
$config['maintain_ratio'] = TRUE;

however on resize just width changes. How to change the height in proportion to width

the code follows

Code:
$imgpath = realpath("public/logo/".$resarr['file_name']);
$config['image_library'] = 'GD2';
$config['source_image'] = $imgpath;
$config['maintain_ratio'] = TRUE;
$config['width'] = 200;            
$this->load->library('image_lib', $config);
$this->image_lib->resize();


  Calendar question
Posted by: El Forum - 08-23-2007, 07:54 AM - Forum: Archived General Discussion - Replies (7)

[eluser]postlogic[/eluser]
Hi, just wondering if it's possible to specify other names for days (e.g., another language) in the calendar library.

Something like

Code:
$prefs = array(
    'day_names' = array("man", "tirs", "ons", "tors", "fre", "l&oslash;r", "s&oslash;n")
);

if you catch my drift.

kthx.


  Use of periodically_call_remote
Posted by: El Forum - 08-23-2007, 07:30 AM - Forum: Archived Development & Programming - Replies (2)

[eluser]Unknown[/eluser]
Hi.
I'm using the Ajax library with Code Igniter and I'm doing almost all the Ajax calls using the Ajax.Updater method. I want to make a periodic Ajax call and I think that prototype's periodically_call_remote method should be the solution, but I can't get it working...
Anybody could tell me what should I do to get it working?
I'm doing the Ajax calls from javascript and all the posts I've been reading about periodically_call_remote talk about a type of calls (ruby on rails, I think) that I' ve never used.
I'm a little lost right now... anybody have used it? Could you explain me a little about periodically_call_remote?

Thanks!
subiroff


  Problem with inheritance
Posted by: El Forum - 08-23-2007, 06:06 AM - Forum: Archived Development & Programming - Replies (8)

[eluser]masterix[/eluser]
I haven't found it so I post here.

I have following dependence hierarchy in my project:

Code:
class Admin extends Controller
class NewsAdmin extends Admin
class ArtAdmin extends Admin
class ConfigAdmin extends Admin

The problem occurs when I invoke NewsAdmin controller. CI doesn't know anything about Admin class. It can be solved by adding:
Code:
require_once('admin.php');
but this solution isn't nice for me. Is there any other ?

Thanks in advance for help.


  help!how to use 'redirect' to retrun a url like 'listview/index/' not "listview/index"
Posted by: El Forum - 08-23-2007, 04:27 AM - Forum: Archived General Discussion - Replies (1)

[eluser]Unknown[/eluser]

Code:
function update(){
        $this->get_result->doupdate();
        //echo "sucess";
        redirect('listview/index/');
    }


it returns a url "index.php/listview/index"
But, that I want is "index.php/listview/index/"

I am so sorry my English is very poor!!
Have you known my doctrine's?
thank you


  validation : return formatted rule fields
Posted by: El Forum - 08-23-2007, 03:28 AM - Forum: Archived General Discussion - Replies (2)

[eluser]xwero[/eluser]
I don't know if it's possible so i want to ask it first.

The idea behind it is simple. You have all those rules to validate the input and when the validation succeeds you can use the rules instead of doing the same thing over again with the post variables.

In code this would be something like this

Code:
$this->load->library('validation');
        
$rules['username'] = "trim|required|min_length[5]|max_length[12]|xss_clean";
$rules['password'] = "trim|required|matches[passconf]|md5";
$rules['passconf'] = "trim|required";
$rules['email'] = "trim|required|valid_email";
    
$this->validation->set_rules($rules);
    
$fields['username']    = 'Username';
$fields['password']    = 'Password';
$fields['passconf']    = 'Password Confirmation';
$fields['email']    = 'Email Address';

$this->validation->set_fields($fields);
        
if ($this->validation->run() == FALSE)
{
    $this->load->view('myform');
}
else
{
    $this->model->add($this->validation->username,$this->validation->password,$this->validation->passconf,$this->validation->email);
    $this->load->view('formsuccess');
}

I tested this example but the $this->validation->username returned the post variable.


  url routing to dynamic file name
Posted by: El Forum - 08-23-2007, 12:19 AM - Forum: Archived Development & Programming - Replies (8)

[eluser]RaZoR LeGaCy[/eluser]
I need

Code:
http://www.hellhorror.com/demon-names-16.html
to go to
Code:
http://www.hellhorror.com/demons/demonology/16/DYNAMIC-NAME.html
with a header of 301 permanent redirect

How may I do it??
In routing, a seperate file that checks the segment then checks the DB and inserts the file-name?

Best optimized solution please.



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.