Re: Common Startup controller

2007-10-02 Thread SmartWeird

> copy app_controller.php to /app/app_controller.php

thanx so much , i didn't know that cakephp looks for another
app_controller.php in app directory



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Common Startup controller

2007-10-01 Thread SmartWeird

hi there

im kinda new to cakephp, just 3 simple website i've done using it
but now im facing a problem, my web site has two language , english
and arabic, im loading a global array of language ($lang['var'] =
$word) from DB table called lang, i constructed the following

* 'Lang' Model
* 'LangController' Controller
no view

an example url : www.example.com/news/view/1// this should
displayed in the default language which is arabic

another url: www.example.com/en/news/view/1  // obviously this is
should be in english

so i need to put a code to be run before any other controller, that
load the global lang array and remove '/en/' from url and dispatch the
new correct url internaly


my idea that i got for this (and i know it's so bad) :
in file /cake/app_controller.php

class StartupController extends Controller {

var $definedLangs = array('ar', 'en');

function __construct() {
parent::__construct();
$this->redirectToLang();
}


function redirectToLang()
{
//code to get controller name

if($this->isLang($langcode))
{
// dispatching new url

}
else
{  // default
$this->loadLang('ar');
}
}

// check if the missing controller is lang or not
function isLang($name)
{
//code
}

function loadLang($langcode = 'ar')
{
loadModel('Lang');
$lng = new Lang();
$arr = $lng->findAll();

global $lang;
$lang = array();

foreach($arr as $index)
$lang[$index['Lang']['var']] = 
$index['Lang'][$langcode];

return $lang;
}



}

class AppController extends StartupController {


}

im sure writing code in cake dir is extremely bad . so any ideas ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Dynamic page titles and keywords.

2007-10-01 Thread SmartWeird

in your view you can put

$this->viewVars['keywords'] = 'my, keywords, etc.';

then the variable $keyword will be defined in your layout

enjoy



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---