How to use a partial view from a different module in Zend?
Asked Answered
S

2

10

I'm trying to access a partial view in foo from another module bar. Simplified file structure:

application/
    modules/
        foo/
            index.phtml
        bar/
            partial.phtml

And in index.html you would have the following code:

<?php echo $this->partialLoop('../bar/partial.phtml', $this->paginator);
echo $this->paginator; ?>

The problem is that you can't actually use parent traversal, as I get this error:

Requested scripts may not include parent directory traversal ("../", "..\" notation)

Is there any way to still include the partial view into my content page? (Or am I doing it wrong?) Thanks in advance.

Sybilla answered 8/4, 2011 at 19:53 Comment(0)
S
17

You need to pass the module argument:

<?php echo $this->partialLoop('partial.phtml', 'bar', $this->paginator); ?>
Saddlecloth answered 8/4, 2011 at 20:0 Comment(2)
Oh, brilliant; thanks a lot. Suppose this is valid for helpers as well?Sybilla
Depends on what youre trying to access and how. Take a look at the API or full documentation for the helper or component in question.Saddlecloth
S
7

I have gone through the same issue. I had to include views from one module into another module's views. I have solved the issue by adding the script path within the controller of the view (in which I had to include the other view)

$this->view->addScriptPath(APPLICATION_PATH.'/modules/moduleName/views/scripts/actionName');

and then included the script within the view file:

<?php 
    echo $this->render('common-header.phtml');
    //Name of the file you want to include 
?>
Shopworn answered 18/4, 2013 at 11:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.