HOW TO install ApPHP Tabs with CakePHP?

Discuss everything related to ApPHP Tabs. Any questions related to the ApPHP Tabs developing or using should be posted to this forum.

Moderators: alexandrleonenko, Milton

Posts: 2
Joined: Feb 4th, '11, 20:31

HOW TO install ApPHP Tabs with CakePHP?

Postby glkaup » Feb 4th, '11, 20:41

I've been using the CakePHP framework for about 6 months... Now, I'd like to add ApPHP Tabs and other Ap??? products to it. Has anyone done this setup? It looks like the path definitions could be messy?

Thanks in advance for any info?
Last edited by glkaup on Feb 10th, '11, 20:31, edited 1 time in total.

Posts: 2
Joined: Feb 4th, '11, 20:31

Re: Install ApPHP Tabs with CakePHP

Postby glkaup » Feb 9th, '11, 21:41


Well, I got it working... and it's great. Here is a stab at trying to explain what I did to get it working:

Install ApPHP Tabs into the CakePHP app/plugins/apphp_tabs/webroot folder.
Make a new folder app/plugins/apphp_tabs/css
Move the /styles/ to the css folder.
Move the gifs and css in the /styles/ folder to the css/ folder
Leave the styles/ folder and its various "style type" sub folders alone!
MOVE the examples/content/ folder to app/webroot/content/

RENAME the file tabs.class.php to tabs_class.php!

I already had jQuery loaded for cake at /app/webroot/js and it was being loaded for every controller in my /app/views/layouts/default.ctp However, the jquery.dropdown.js was not there. I left this js in the /app/plugins/apphp_tabs/webroot/js folder and it was easily loaded later!

Create the file app/plugins/apphp_tabs/webroot/config/tabs_config.php

Code: Select all

// if NOT running CakePHP
//if (!defined('TABS_DIR')) {
//   define('TABS_DIR', "../");

// If running CakePHP
if (!defined('TABS_CAKE_PLUGIN_NAME'))
   define('TABS_CAKE_PLUGIN_NAME', 'apphp_tabs');

if (!defined('TABS_DIR')) {
   define('TABS_DIR',  APP . 'plugins' .DS. TABS_CAKE_PLUGIN_NAME .DS. 'webroot' .DS);

NOW... Ready to work on the Cake part!

Then, add

Code: Select all

App::import('Plugins', 'apphp_tabs.tabs_class.php');
to the controller you want to use tabs in. I only wanted tabs in one controller for now! Otherwise, place this import function in your /app/app_controller.php

In your view.ctp file use:

Code: Select all

$tabs = new Tabs(1, 'grey', "Caption for Tabs Menu!", &$this);
// NOTICE the extra argument used to pass the CakePHP object into the Tabs class.


Code: Select all

BEFORE the beginning of the tabs_class.php

At the end of the private variable section of the tabs_class add:

Code: Select all

    private $codedTabs;
    private $myCakeParent=null;         // for access to CakePHP functions
    private $myCakeVersion=null;

Change the constructor call to:

Code: Select all

    public function __construct($id=1,$style="light-green",$caption="", &$cakeObject = null)

Change the end of the constructor to:

Code: Select all

      if(defined("TABS_DIR")) $this->path = TABS_DIR;
       else $this->path = "";
       // Setup to run with CakePHP, but make sure we have a valid CakePHP object!
       $this->myCakeParent = &$cakeObject;
       if (!empty($this->myCakeParent)) {
            if (!class_exists('Configure', false)) {
               $this->myCakeParent = null;
            } else if (!method_exists('Configure', 'read')) {
               $this->myCakeParent = null;
            } else {
               $this->myCakeVersion = Configure::read('Cake.version');
               if ($this->myCakeVersion < "1.3.7") {
                  $this->myCakeParent->Session->setFlash('ApPHP Tabs requires at least CakePHP v1.3.7');
                  $this->myCakeParent = null;
                  $this->myCakeVersion = null;
       // End setup to run with CakePHP

Change the LoadFiles function to:

Code: Select all

   private function LoadFiles()
      if (!empty($this->myCakeParent)) {
         // If use: "/plugin_name/js/my_file.js"
         // Then, links to: "app/plugins/plugin_name/webroot/js/my_file.js"
         // TABS css
         //echo $this->myCakeParent->Html->css('/apphp_tabs/css/styles/' . $this->style . '/style');
         //echo $this->myCakeParent->Html->css('/apphp_tabs/css/common');
             //echo  "\n<!--[if IE]>";
         //   echo $this->myCakeParent->Html->css('/apphp_tabs/css/commonIE');
           //echo "<![endif]-->\n";
         echo $this->myCakeParent->Html->css('/'. TABS_CAKE_PLUGIN_NAME . '/css/styles/' . $this->style . '/style');
         echo $this->myCakeParent->Html->css('/'. TABS_CAKE_PLUGIN_NAME . '/css/common');
             echo  "\n<!--[if IE]>";
            echo $this->myCakeParent->Html->css('/'. TABS_CAKE_PLUGIN_NAME . '/css/commonIE');
           echo "<![endif]-->\n";
           // Tabs js
         echo $this->myCakeParent->Html->script('/'. TABS_CAKE_PLUGIN_NAME . '/js/script');
         echo $this->myCakeParent->Html->script('/'. TABS_CAKE_PLUGIN_NAME . '/js/jquery.dropdown.js');
      } else {
             echo  "<link href='".$this->path."styles/".$this->style."/style.css' rel='stylesheet' type='text/css' />";
             echo  "\n<link href='".$this->path."styles/dropdown.css' rel='stylesheet' type='text/css' />";
             echo  "\n<link href='".$this->path."styles/common.css' rel='stylesheet' type='text/css' />";
             echo  "\n<script type='text/javascript' src='".$this->path."js/script.js'></script>";
          echo "\n<script type='text/javascript' src='".$this->path."js/jquery-1.4.2.min.js'></script>";
          echo  "\n<!--[if IE]>";
          echo "<link href='".$this->path."styles/commonIE.css' rel='stylesheet' type='text/css' />";
                 echo "<![endif]-->\n";
          echo "\n<script type='text/javascript' src='".$this->path."js/jquery.dropdown.js'></script>";

Now, this makes everything display properly... Still have to work on all of the links, etc.

Site Admin
Site Admin
Posts: 6125
Joined: Jan 7th, '09, 23:18

Re: HOW TO: Install ApPHP Tabs with CakePHP

Postby administrator » Feb 13th, '11, 09:42


Return to “ApPHP Tabs”