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.

4

2 回答 2

16

You need to pass the module argument:

<?php echo $this->partialLoop('partial.phtml', 'bar', $this->paginator); ?>
于 2011-04-08T20:00:26.457 回答
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 
?>
于 2013-04-18T11:05:14.737 回答