Hello,

I am new to Cake PHP and am experimenting with it prior to hopefully 
using it to develop code for real clients.  I am likely to have to 
deploy the eventual project on a shared server and I can't assume I'll 
have mod_rewrite available to me.  So I have chosen to use Cake pretty 
URLs, which I think should be fine for my intended client.

I have developed a little app for outputting news items, closely 
following the blog tutorial.  I downloaded a component and helper suite 
from the Bakery to enable pagination of the record set.  There seems to 
be a problem whenever this helper uses $html->link to generate a URL 
e.g. for next/previous page, or for changing the sort by criterion on a 
heading.  This seems to be entirely down to two properties in the 
controller class being set to odd values viz:

$this->here = 
/workspace/myclient/index.php/workspace/myclient/news_items/index
$this->base =
/workspace/myclient/index.php/workspace/myclient

I call up the controller by:

http://localhost/workspace/myclient/index.php/news_items/index

The output I get is as expected as far as the list of items is 
concerned, though all the generated URLs from the paginator are wrong. I 
can't understand why Cake is inserting the extra "/workspace/myclient" 
into these two URL properties, here and base.  It is certainly causing 
the paginator to generate URLs like:

http://localhost/workspace/myclient/index.php/workspace/myclient/news_items/index/?page=2

rather than:

http://localhost/workspace/myclient/index.php/news_items/index/?page=2

The former not surprisingly moans about a missing workspace controller!

I have set my local environment up (on Fedora Core Linux) as follows 
(changing the set directory pattern as I am likely to have to do this 
when I deploy live):

My application is in /home/davidh/workspace/myclient (there is a 
symbolic link "workspace" in the Apache server root /opt/lampp/htdocs 
which points to /home/davidh/workspace). /home/davidh/workspace/myclient 
is intended to be the web root where css, img etc directories are.  The 
class files are in a subdirectory /home/davidh/workspace/myclient/app.

I have commented out all mod_rewrite directives in the .htaccess file in 
/home/davidh/workspace/myclient and /home/davidh/workspace/myclient/app. 
  I have kept these files as I have needed to set php_flag

session.use_trans_sid 0

as I kept getting session ids in my URLS in my browser, despite wanting 
to use cookies. BTW looking at the cookie path that had been set in my 
browser, it had the same odd path and was clearly generated from 
controller "here" property.  Which probably meant the session id 
functionality wasn't using the cookie as the path was screwed up.

In the top level index.php in /home/davidh/workspace/myclient I have set 
the following:

if (!defined('ROOT')) {
                 //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY 
IS 
LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
                 //You should also use the DS define to seperate your 
directories
                 //define('ROOT', dirname(dirname(dirname(__FILE__))));
                 define('ROOT', dirname(__FILE__));
        }
        if (!defined('APP_DIR')) {
                 //define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
                                        
//define('APP_DIR',basename(dirname(dirname(__FILE__))));
                 define('APP_DIR', 'app');
        }       
/**
  * This only needs to be changed if the cake installed libs are located
  * outside of the distributed directory structure.
  */
        if (!defined('CAKE_CORE_INCLUDE_PATH')) {
                 //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY 
WHERE CAKE 
CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
                 //You should also use the DS define to seperate your 
directories
                 //define('CAKE_CORE_INCLUDE_PATH', ROOT);
                 define('CAKE_CORE_INCLUDE_PATH', 
DS.'opt'.DS.'lampp'.DS.'htdocs'.DS.'cakephp');

(I want the Cake libraries to reside outside of the workspace structure).

Can anyone shed some light on what I'm doing wrong here?  I can hack 
around the problem by putting the line:

$this->base = BASE_URL;

(BTW I have done:

define ('BASE_URL', env('SCRIPT_NAME'));

in core.php so I turn off mod_rewrite).

in every method of my controller that needs to generate a URL (this 
works), but I'd rather understand why I'm having this problem!

Thanks in advance for any help people can give.

David Herbert
Cambridge UK.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to