Updated Resource Page and February Meeting Planning

38 views
Skip to first unread message

Chris Tankersley

unread,
Jan 23, 2012, 10:19:01 AM1/23/12
to nwo...@googlegroups.com
I've updated the resource page for January's ZCE talk and the slides
from the Intro to Zend Framework. I also posted a link to the book Roger
recommends to read through to get your MySQL Certification. This can all
be found at http://www.nwo-pug.org/resources .

For February, I won't be able to make it due to a prior conflict, so for
February anyone who wants to present anything just e-mail me. The
meeting should take place on Feb 21st.

--
Chris

Bud Manz

unread,
Jan 23, 2012, 5:18:56 PM1/23/12
to nwo...@googlegroups.com
I can possibly do a presentation on writing a component for Joomla
1.7. If there is any interest in that.

Bud

Sent from my iPhone

Thomas Powers

unread,
Feb 21, 2012, 2:37:17 PM2/21/12
to nwo...@googlegroups.com
Wondered if anyone here could help out. I've setup a new Zend Framework skeleton for the new design of our company website. In the PHP script, I create a new view.

[code]
$view = new Zend_View();
$view->setScriptPath(APPLICATION_PATH . "/views/scripts/menu");

/* skip some stuff */

$view->render('nameofscript.php');
[/code]

I get Zend_View_Exception with message: "script "nameofscript.php" not found in path (/path/to/script/views/scripts/menu/). However, the script is located in the folder specified (on the server side--yes I checked). Anybody have a clue how to resolve this?

Thanks,

THOMAS POWERS | SENIOR WEB DEVELOPER |
GERMAN MUTUAL INSURANCE
Work: (419) 599-3993 Ext: 252 | Mobile: (419) 591-6064 |
Email: thomas...@heartland-ins.com | Website: http://www.heartland-ins.com
Tuesdays & Fridays: (419) 966-4079

Ron Paul - VOTE FOR FREEDOM!

"True patriotism is more closely linked to dissent than it is to conformity and a blind desire for safety and security." - Congressman Ron Paul (TX)

Thomas Powers

unread,
Feb 21, 2012, 2:39:43 PM2/21/12
to nwo...@googlegroups.com
LOL. I just needed to send the email I guess. As soon as I sent it, I realized what the problem was. The path included the module path as well, but I wasn't putting that in the "setScriptPath" statement.

Thanks,

THOMAS POWERS | SENIOR WEB DEVELOPER |
GERMAN MUTUAL INSURANCE
Work: (419) 599-3993 Ext: 252 | Mobile: (419) 591-6064 |
Email: thomas...@heartland-ins.com | Website: http://www.heartland-ins.com
Tuesdays & Fridays: (419) 966-4079

"True patriotism is more closely linked to dissent than it is to conformity and a blind desire for safety and security." - Congressman Ron Paul (TX)

Thanks,

--
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.

Chris Tankersley

unread,
Feb 21, 2012, 2:40:21 PM2/21/12
to nwo...@googlegroups.com
Try leaving off the .php part of the render() call, and rename the file
to 'nameofscript.phtml' and see if that works. I think Zend_View does
some magic to find the templates including building the name of the file
itself.

-Chris

On 2/21/2012 2:37 PM, Thomas Powers wrote:
> Wondered if anyone here could help out. I've setup a new Zend Framework skeleton for the new design of our company website. In the PHP script, I create a new view.
>
> [code]
> $view = new Zend_View();
> $view->setScriptPath(APPLICATION_PATH . "/views/scripts/menu");
>
> /* skip some stuff */
>
> $view->render('nameofscript.php');
> [/code]
>
> I get Zend_View_Exception with message: "script "nameofscript.php" not found in path (/path/to/script/views/scripts/menu/). However, the script is located in the folder specified (on the server side--yes I checked). Anybody have a clue how to resolve this?
>
> Thanks,
>
> THOMAS POWERS | SENIOR WEB DEVELOPER |
> GERMAN MUTUAL INSURANCE
> Work: (419) 599-3993 Ext: 252 | Mobile: (419) 591-6064 |
> Email: thomas...@heartland-ins.com | Website: http://www.heartland-ins.com

> Tuesdays& Fridays: (419) 966-4079

Thomas Powers

unread,
Feb 22, 2012, 12:18:55 PM2/22/12
to nwo...@googlegroups.com
Okay. Now I am having an issue with modules. I cannot get the app to "see" my module. First off, I feel quite comfortable with ZF, but when it comes to modules, I get wrapped up in confusion. I'll try to explain the best that I can.

Portion of Config File (below)

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""

---------------End File-------------

Portion of Bootstrap File (below)

protected function _initAutoloadModules()
{
$moduleLoader = new Zend_Application_Module_Autoloader(
array (
'namespace' => '',
'basePath' => APPLICATION_PATH
),
array (
'namespace' => 'docs',
'basePath' => APPLICATION_PATH . '/modules/docs'
)
);

return $moduleLoader;
}

protected function _initFCPlugins()
{
Zend_Layout::starMvc();
$this->bootstrap('frontController');
$this->bootstrap('RegisterNamespaces');

$fc = $this->getResource('frontController');
$fc->registerPlugin(new Tws_Controller_Plugin_ModuleLayout());
$fc->registerPlugin(new Gmic_Plugin_Module());

return $fc;
}

class Gmic_Plugin_Module extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName();
$layout = Zend_Layout::getMvcInstance();

$layoutsDir = $layout->getLayoutPath();

if (file_exists($layoutsDir . DIRECTORY_SEPARATOR . $module . ".phtml")) {
$layout->setLayout($module . "-layout");
} else {
$layout->setLayout('layout');
}
}
}

---------------End File--------------


I'm trying to access APP_PATH . "/agent/docs/index". There are two modules, I have the default and then docs (at this point). As you can see from the parameters list at the bottom, the module is docs, the controller is index, yet it doesn't "exist".

<***** ERROR THAT I GET ******>

An error occurred
Page not found
Exception information:

Message: Action "index" does not exist and was not trapped in __call()
Stack trace:

#0 /var/www/projects/powerst/shared-library/Zend/Controller/Action.php(515): Zend_Controller_Action->__call('indexAction', Array)
#1 /var/www/projects/powerst/shared-library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#2 /var/www/projects/powerst/shared-library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#3 /var/www/projects/powerst/shared-library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
#4 /var/www/projects/powerst/shared-library/Zend/Application.php(346): Zend_Application_Bootstrap_Bootstrap->run()
#5 /var/www/projects/powerst/agent/public/index.php(35): Zend_Application->run()
#6 {main}

Request Parameters:

array(3) {
["module"]=>
string(4) "docs"
["controller"]=>
string(5) "index"
["action"]=>
string(5) "index"
}

------------- END ERROR ------------

I have a bootstrap for the docs module, as well. The IndexController for Docs is Docs_IndexController. Anyone know what I'm missing here?

THOMAS POWERS | SENIOR WEB DEVELOPER |
GERMAN MUTUAL INSURANCE
Work: (419) 599-3993 Ext: 252 | Mobile: (419) 591-6064 |
Email: thomas...@heartland-ins.com | Website: http://www.heartland-ins.com

Tuesdays & Fridays: (419) 966-4079

"True patriotism is more closely linked to dissent than it is to conformity and a blind desire for safety and security." - Congressman Ron Paul (TX)

Chris Tankersley

unread,
Feb 29, 2012, 4:26:33 PM2/29/12
to nwo...@googlegroups.com
Hey, I built some of that!

On Wed, Feb 22, 2012 at 12:18 PM, Thomas Powers <Thomas...@heartland-ins.com> wrote:
Okay. Now I am having an issue with modules. I cannot get the app to "see" my module. First off, I feel quite comfortable with ZF, but when it comes to modules, I get wrapped up in confusion. I'll try to explain the best that I can.

Portion of Config File (below)

resources.frontController.moduleDirectory       = APPLICATION_PATH "/modules"
resources.modules[]                             = ""

---------------End File-------------

This is correct. All your modules should reside in folders inside APPLICATION_PATH/modules, so a new module called mynewmodule would be in APPLICATION_PATH/modules/mynewmodules. 

The second line tells it to load all the modules in the directory.
 

Portion of Bootstrap File (below)

protected function _initAutoloadModules()
{
       $moduleLoader = new Zend_Application_Module_Autoloader(
                       array (
                               'namespace' => '',
                               'basePath'      => APPLICATION_PATH
                       ),
                       array (
                               'namespace' => 'docs',
                               'basePath'      => APPLICATION_PATH . '/modules/docs'
                       )
     );

     return $moduleLoader;
}

You shouldn't need to do this. This is taken care of by the individual bootstrap for each module.
 

protected function _initFCPlugins()
{
       Zend_Layout::starMvc();
     $this->bootstrap('frontController');
     $this->bootstrap('RegisterNamespaces');

       $fc = $this->getResource('frontController');
       $fc->registerPlugin(new Tws_Controller_Plugin_ModuleLayout());
       $fc->registerPlugin(new Gmic_Plugin_Module());

     return $fc;
}

class Gmic_Plugin_Module extends Zend_Controller_Plugin_Abstract
{
       public function preDispatch(Zend_Controller_Request_Abstract $request)
       {
               $module         = $request->getModuleName();
               $layout         = Zend_Layout::getMvcInstance();

               $layoutsDir = $layout->getLayoutPath();

               if (file_exists($layoutsDir . DIRECTORY_SEPARATOR . $module . ".phtml")) {
                       $layout->setLayout($module . "-layout");
               } else {
                       $layout->setLayout('layout');
               }
       }
}


Gmic_Plugin_Module seems to be doing the same thing as what Tws_Controller_Plugin_ModuleLayout() is intended to do, which is flip the layout file based on the module name. So you could probably get rid of it.
It all sounds correct. Your directory layout should look like this:

/path/to/application/
    application/
        configs/
        controllers/
        forms/
        layouts/
        models/
        modules/
            docs/
                controllers/
                forms/
                ....
        views/

Make sure that you have a bootstrap class in application/modules/docs/Bootstrap.php that looks like this one: https://github.com/dragonmantank/manuscript/blob/master/application/modules/accelerators/Bootstrap.php (replace Accelerators_Boostrap with Docs_Bootstrap). That should cause ZF to see your module controllers.

My guess is all that is correct, and if it is I think you're just missing the indexAction() method in Docs_IndexController. So it would look like this:

class Docs_IndexController extends Zend_Controller_Action
{
    public function indexAction() {
        // Logic for this page
    }
}
 

THOMAS POWERS | SENIOR WEB DEVELOPER |
GERMAN MUTUAL INSURANCE
Work: (419) 599-3993 Ext: 252 | Mobile: (419) 591-6064 |
Email: thomas...@heartland-ins.com | Website: http://www.heartland-ins.com
Tuesdays & Fridays: (419) 966-4079

"True patriotism is more closely linked to dissent than it is to conformity and a blind desire for safety and security." - Congressman Ron Paul (TX)



--
Chris Tankersley
http://ctankersley.com
419.785.6408
Reply all
Reply to author
Forward
0 new messages