
Ravani
Members-
Posts
19 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Ravani's Achievements

Newbie (1/5)
0
Reputation
-
Hi everyone, I have developed a CMS with Zend but I'm not really happy with my plugins structure and I have decided to change it. I just like to know if it is easy to achieve what I want. This is the application structure: -- Application --- configs --- controllers --- forms --- models --- modules ---- admin ----- controllers ----- models ----- views ----- bootstrap.php --- views --- bootstrap.php What I want to do is add a directory named plugins under the map application and create a plugin structure like this: --- plugins ---- pages ----- contact ------ backend ------- ContactBackendController.php ------- views ------ frontend ------- ContactFrontEndController.php ------- views When you want to add a normal page you just go to admin/page/add , however when you want to add a contact page you will be redirected to the add action in the ContactBackendController. Is that possible and is that a smart way to handle this or are there better ways?
-
You're right, however I'm getting this error: Fatal error: Declaration of LoginController::__construct() must be compatible with that of Zend_Controller_Action_Interface::__construct() in Seems like I need to add some arguments in the constructor but I don't really know which one.
-
Thanks a constructor would be a good solution indeed, however it seems that the Zend Framework has trouble with that. So using DB_Object::getInstance() will be a good solution as well?
-
Hi everyone, I was discussing this topic with one of my friends and both of us can't give a real answer to this. Example: class test { function a(){ $obj = new DB_TableObject(); //blabla bla $this->b($obj); } function b($object){ $object->getResults(); } } class test { function a(){ $obj = new DB_TableObject(); //blabla bla $this->b($obj); } function b(){ $obj = new DB_TableObject(); $object->getResults(); } } Which one is better? The first or the second solution?
-
Thanks, works good !
-
Thanks, do you have a simple example of that?
-
Hi, I was wondering if anyone here has experience with the best way to preview a form? I want two buttons on the bottom of my form: submit and preview. When a visitor clicks on preview he will be given a preview of the submitted values where he can go back to make changes or click on submit to commit the values. Anyone has an idea to do this? Thanks!
-
Ok thanks, I read the documentation and came to the conclusion that this is the easiest way for me to use it: function replaceContent($sContent) { $sContent = preg_replace_callback("'\[MENU-CARD\](.*?)\[/MENU-CARD\]'is", array($this,'loadMenuCard'), $sContent); $sContent = preg_replace_callback("'\[CONTACT-FORM\]'is", array($this,'loadContactForm'), $sContent); return $sContent; }
-
Yeah I can't get to PHP.net at all.
-
Ok I solved the problem by putting loadMenuCard inside the replaceContent function. This way I can call the function without using $this-> However I'm not sure if this is a good solution though. If hope one of you guys know a better solution
-
@MrAdam, I'm using your advice now however I'm getting an error. This is what I have now function replaceContent($sContent) { $aReplaceTags = array( "'\[MENU-CARD\](.*?)\[/MENU-CARD\]'is", "'\[CONTACT-FORM\]'is", ); $oLoadMenu = '$this->loadMenuCard'; //$oContactForm = 'process'; foreach($aReplaceTags as $aTag){ if($aTag == "'\[MENU-CARD\](.*?)\[/MENU-CARD\]'is"){ $sContent = preg_replace_callback($aTag, $oLoadMenu, $sContent); } } return $sContent; } And this is what I'm getting: Warning: preg_replace_callback() [function.preg-replace-callback]: Requires argument 2, '$this->loadMenuCard', to be a valid callback in C:\wamp\www\SamandCMS\application\views\helpers\ReplaceContent.php on line 39
-
I saw it in an example. However I changed it into one backslash, it works for a simple output: "/\[MENU-CARD\](\w+)\[\/MENU-CARD\]/e" => '\1', This gives 2 as output but the output inside the function will be \1 again when using this: "/\[MENU-CARD\](\w+)\[\/MENU-CARD\]/e" => $this->loadMenuCard('\1'), When I output the $aReplaceTags array I get: Array ( [/\[MENU-CARD\](\w+)\[\/MENU-CARD\]/e] => \1 ['\[CONTACT-FORM\]'is] => Contactformulier ) That \1 should be 2 though.
-
Thanks for the replies, I'm confused now. I tried the example: $aReplaceTags = array( "/\[MENU-CARD\](\w+)\[\/MENU-CARD\]/e" => $this->loadMenuCard('\\1'.strtoupper('\\2').'\\3'), "'\[CONTACT-FORM\]'is" => "Contactformulier", ); I still get the same result. If I output this value '\\1'.strtoupper('\\2').'\\3' outside of the function it gives me 2 which is correct however when I use the loadMenuCard function it gives me '\1\2\3' as output.
-
I'm trying to use preg_replace but I can't get it working. function replaceContent($sContent) { $aReplaceTags = array( "'\[MENU-CARD\](.*?)\[/MENU-CARD\]'is" => '\\1', "'\[CONTACT-FORM\]'is" => "Contactform", ); return preg_replace(array_keys($aReplaceTags), array_values($aReplaceTags), $sContent); } This works great however when I change '\\1' into a function the output of '\\1' will always be 1. function replaceContent($sContent) { $aReplaceTags = array( "'\[MENU-CARD\](.*?)\[/MENU-CARD\]'is" => $this->loadMenuCard('\\1'), "'\[CONTACT-FORM\]'is" => "Contactform", ); return preg_replace(array_keys($aReplaceTags), array_values($aReplaceTags), $sContent); } Anyone knows what I am doing wrong?
-
For those who are interested, the solution was quite simple. I deleted the local db parameters from the ini file and editted my _initDbRegistry function inside the bootstrap into: public function _initDbRegistry() { $this->bootstrap('multidb'); $multidb = $this->getPluginResource('multidb'); $dbName = $this->loadDatabase('customer'); $dbCustomer = array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => $dbName, 'default' => true,); $dbCustomerAdapter = new Zend_Db_Adapter_Pdo_Mysql($dbCustomer); Zend_Db_Table::setDefaultAdapter($dbCustomerAdapter); Zend_Registry::set('db_local', $dbCustomerAdapter); Zend_Registry::set('db_remote', $multidb->getDb('remote')); }