Tuesday, September 6, 2011

Tip: Rendering a different view in another view from a different module

Say you have want to retrieve a view from another module and you have this directory structure

/modules/
    /front
        /controllers
            /front-controller-one
        /views
            /scripts
                /front-controller-one
                    /front-view.phtml
    /back
        /controllers
             /back-controller-two
        /views
            /scripts
                /back-controller-two
                    /back-view.phtml

From your controller (say you are in front-controller-one in "front" module):
$frontControllerDir = $this->getFrontController()->getControllerDirectory('back'); // retrieve controller dir of the mentioned MODULE
$this->view->addBasePath(realpath($frontControllerDir . '/../views')); // do NOT add the "scripts" dir as it will be added automatically so do NOT do this: '/../views/scripts'

The script above will add a base path of Back modules view/scripts directory to the View objects script paths so if you do print_r($this->view->getScriptPaths()) you should be able to see the new path you added above in the list.

Now from your view (/front/view/scripts/front-controller-one/front-view.phtml):
<div id="journalEntryView"><?php echo $this->render('back-controller-two/back-view.phtml'); ?></div>

20 comments:

Anonymous said...

Thanks.. It has helped me even a year later... :)

Unknown said...

Sergei , October 22, 1970 Born in Christian Louboutin Bois Dore Moscow State Ozherelye. Perhaps influenced by Cheap LV Handbags their parents worship warrior army, join the army in cheap jordans 1989, and into the elite airborne military service. 1991, by the influence of the Soviet Union, the uggs on sale Russian christian louboutin army general lack of funds, a large number ugg australia of Air Jordan 11 Gamma Blue soldiers seeking veterans, but under extremely difficult conditions still dedicated, praise superiors, and soon was sent to the famous christian louboutin shoes Ryazan Higher ugg Airborne Command School studies. After graduating in 1994, entered the famous Pskov 76th Guards Airborne discount christian louboutin Division, served as discount nike jordans the reconnaissance platoon, reconnaissance ugg soldes deputy company commander, company commander, battalion airborne regiment scouting director and other duties.From 2000 to Cheap Louis Vuitton Handbags 2004, where the forces have repeatedly ordered war with Chechen militants. Because of their opponents in order to form the squad activity and haunted impermanence, the Russians had to ugg boots mobilize elite troops set up large uggs outlet number of small units, "a Discount Louis Vuitton small wholesale jordan shoes play small" Implementation siege. commanding troops in Chechnya, Christian Louboutin Daffodile Ingushetia and other places over the mountains, to track the militants fled. Discount LV Handbags Although the militants were extremely vigilant, but as long as the task has never had outsmarted.August 8, 2008, Georgia suddenly invade South Ossetia (Russian peacekeepers stationed ugg pas cher there), the Russian military to respond quickly, including including the 76th Guards Airborne Division, more than christian louboutin remise 50% 3,000 people were immediately delivered to the pro-Russian Abkhazia, Georgia cheap nike jordan shoes Army contain two infantry brigades, effectively coordinate the cheap christian louboutin direction of the Russian Bags Louis Vuitton troops in South Ossetia.

Unknown said...

new york giants jerseys
juicy couture outlet
chanel outlet
ray ban sunglasses
robert griffin jersey,joe theismann jersey,andre roberts jersey,sonny jurgensen jersey,art monk jersey,bashaud breeland jersey,barry cofield jersey,perry riley jersey,e.j. biggers jersey,duke ihenacho jersey,josh morgan jersey
mizuno shoes
seahawks jersey
stuart weitzman sale
nike free,nike free run,free running,free run,nike running
five fingers shoes
tory burch outlet online
uggs outlet
cheap oakley sunglasses
cheap jordans
mizuno running shoes
derrick rose jersey
cowboys jerseys
barcelona soccer jersey
bottega veneta wallet
nike roshe
chanel outlet,chanel handbags,chanel bags,chanel outlet,chanel 2.55
supra shoes
giants jersey
stephen curry jersey
miami dolphins jerseys
bottega veneta outlet
indianapolis colts jerseys
nike air max 2015
ray ban outlet
arizona cardinals jerseys
the north face clearance
coach outlet store
nike trainers
chelsea jersey
washington redskins jerseys
zhuweiming0627

Unknown said...

15.07.20fangyanting
soccer jerseys for sale
abercrombie & fitch
kate spade handbags
air jordan uk
longchamp outlet online
pandora charms
rolex watches for sale
coach outlet store online
coach outlet
true religion jeans outlet
pandora bracelets
oakley sunglasses wholesale
ralph lauren polo shirts
kate spade bags
coach outlet
snapbacks hats
toms shoes for women
soccer shoes for sale
ray bans
beats headphones
hollister kids
gucci handbags
cheap oakley sunglasses
replica watches for sale
coach factory outlet
gucci borse
gucci belt
cheap snabacks
hollister outlet
tory burch outlet
kate spade bags
michael kors
air max 2015
longchamp pliage pas cher
mcm outlet online

Unknown said...

ray ban sunglasses, http://www.raybansunglassesonline.us.com/
nike trainers, http://www.niketrainers.me.uk/
gucci handbags, http://www.guccihandbags-outlet.co.uk/
herve leger, http://www.herveleger.us.com/
timberland boots, http://www.timberlandboots.name/
coach outlet online, http://www.coachoutletonline-store.us.com/
michael kors outlet, http://www.michaelkorsoutletcanada.in.net/
juicy couture outlet, http://www.juicycoutureoutlet.net/
calvin klein underwear, http://www.calvinklein.in.net/
ray ban sunglasses, http://www.raybansunglass.us.com/
prada outlet, http://www.pradaoutlet.us/
lululemon outlet, http://www.lululemonoutletstore.in.net/
tory burch shoes, http://www.toryburchshoesoutlet.com/
michael kors outlet, http://www.michaelkorsoutlet.org.uk/
replica watches, http://www.replicawatchesforsale.us.com/
pandora jewelry, http://www.pandorajewelryoutlet.us.com/
nfl jerseys wholesale, http://www.nfljerseys-wholesale.us.com/
michael kors outlet, http://www.michaelkorsoutletonlinstore.us.com/
oakley outlet, http://www.oakleyoutlet.in.net/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
michael kors bags, http://www.michaelkorsbags.uk/
ray ban sunglasses, http://www.ray-bansunglasses.eu.com/
oakley sunglasses, http://www.oakley.in.net/
air max 2015, http://www.airmax2015.in.net/
the north face uk, http://www.thenorthfaces.org.uk/
swarovski outlet, http://www.swarovski-outlet.co.uk/
pandora jewelry, http://www.pandora.eu.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
1002maoqiuyun

chenlina said...

chenlina20151127
cheap air jordans
mont blanc pens
mulberry handbags
louis vuitton bags
cheap oakley sunglasses
nike huarache
replica watches
michael kors outlet online
toms wedges
louis vuitton handbags
ralph lauren uk
uggs boots for women
ray ban sunglasses outlet
nike air max
celine handbags
hollister co
soccer shoes
michael kors outlet clearance
louis vuitton outlet
uggs on sale
pandora jewelry
fake oakley sunglasses
cheap nfl jerseys
coach factory outlet
oakley sunglasses
jordan concords
coach factory outlet
michael kors handbags
beats by dre
burberry outlet
michael kors bag
celine outlet
louis vuitton outlet stores
michael kors outlet
canada goose jackets
oakley sunglasses cheap
polo ralph lauren
louis vuitton handbags
abercrombie and fitch
coach factory outlet
as

chenlina said...

chenlina20151127
cheap air jordans
mont blanc pens
mulberry handbags
louis vuitton bags
cheap oakley sunglasses
nike huarache
replica watches
michael kors outlet online
toms wedges
louis vuitton handbags
ralph lauren uk
uggs boots for women
ray ban sunglasses outlet
nike air max
celine handbags
hollister co
soccer shoes
michael kors outlet clearance
louis vuitton outlet
uggs on sale
pandora jewelry
fake oakley sunglasses
cheap nfl jerseys
coach factory outlet
oakley sunglasses
jordan concords
coach factory outlet
michael kors handbags
beats by dre
burberry outlet
michael kors bag
celine outlet
louis vuitton outlet stores
michael kors outlet
canada goose jackets
oakley sunglasses cheap
polo ralph lauren
louis vuitton handbags
abercrombie and fitch
coach factory outlet
as

chenlina said...

chenlina20160127
michael kors outlet
burberry outlet
chanel handbags
ralph lauren outlet
cheap jordans
beats solo
ugg boots sale
louis vuitton outlet
true religion outlet
gucci handbags
cheap oakley sunglasses
louboutin
air max 95
chanel outlet
mihchael kors outlet online
jordan 11 concord
louis vuitton handbags
gucci outlet
kate spade
ray ban sunglasses
toms shoes
uggs outlet
ray ban sunglasses
nike air max
michael kors handbags
coach outlet store online
oakley sunglasses
coach factory outlet
louis vuitton purses
canada goose jackets
louis vuitton
replica watches
michael kors outlet
louis vuitton outlet stores
ray ban outlet store
marc jacobs handbags
louis vuitton
louboutin pas cher
tiffany and co
cheap oakley sunglasses
as

John said...

asics gel nimbus
stephen curry shoes
louis vuitton outlet online
vans shoes
cartier watches for sale
tiffany jewelry
designer handbags outlet
hollister clothing store
salvatore ferragamo
louis vuitton outlet online
nike free flyknit 3.0
reebok
coach outlet online
omega watches
lebron james shoes 2016
coach outlet
dior sunglasses
adidas superstars
reebok outlet
coach purses
cheap oakley sunglasses
michael kors bags
kate spade outlet online
designer handbags
coach outlet clearance
longchamp bag
cheap nfl jerseys
valentino shoes
air max 90 black
michael kors outlet online
tiffany jewelry outlet
michael kors outlet clearance
201671yuanyuan

Unknown said...

thomas sabo uk
herve leger outlet
coach outlet online
louis vuitton handbags
rolex watches
ugg boots
iphone case
cheap snapbacks
uggs outlet
michael kors outlet online
cartier outlet
michael kors outlet clearance
soccer jerseys
oakley sunglasses
celine outlet
canada goose outlet
coach outlet
futbol baratas
nike air force 1
longchamp outlet
coach outlet
michael kors outlet
ugg outlet
canada goose jackets
hermes birkin
polo ralph lauren
michael kors outlet store
air jordan 4
cheap uggs
tory burch outlet
tiffany and co jewelry
louis vuitton outlet
coach outlet
michael kors bags
ugg boots
chanyuan0913

xumeiqing said...

2016923meiqing
yeezy boost 350
jordan shoes
polo ralph lauren outlet online
true religion outlet
fitflops sale clearance
michael kors outlet online
gucci handbags
red bottoms outlet online
fit flops
pandora jewelry

Unknown said...

20161021 junda
michael kors outlet
oakley sunglasses
ugg sale
juicy couture outlet
longchamp pas cher
tory burch outlet
true religion jeans
rolex watches
swarovski crystal
uggs outlet

Unknown said...


uggs outlet
seattle seahawks jerseys
adidas yeezy 350
ugg slippers
ray ban sunglasses
cheap uggs
pittsburgh steelers jerseys
uggs boots
oakley vault
ray ban sunglasses
louis vuitton outlet
cheap ray ban sunglasses
michael kors outlet
true religion uk
coach outlet online
coach outlet
fitflop shoes
ralph lauren polo
cheap jordans
christian louboutin
louis vuitton outlet
true religion outlet
uggs for women
cheap jordans
canada goose jackets
ray ban glasses
coach outlet
sac longchamp
pandora jewelry
rolex watches
basketball shoes
toms shoes
coach outlet online
ray ban outlet
ray ban wayfarer
oakley sunglasses
christian louboutin uk
canada goose
ugg boots uk
moncler jackets
201611.5wengdongdong


Unknown said...

skechers shoes
yeezy boost 350
ray ban sunglasses
seattle seahawks jerseys
denver broncos jerseys
cheap jordan shoes
new york giants jerseys
nike air huarache
giants jersey
los angeles clippers jerseys

Unknown said...

occhiali da sole ray ban
coach outlet online
ralph lauren outlet
louboutin outlet
coach outlet
true religion jeans outlet
asics outlet
clarks sandals
michael kors handbags
pandora charms outlet
2017.6.27chenlixiang

Unknown said...

jordan shoes
nike outlet
jordan shoes
ralph lauren outlet
ugg outlet
louboutin shoes
michael kors bags
polo ralph lauren outlet
ugg boots
ugg outlet

John said...

yeezy shoes
adidas nmd runner
rangers jerseys
jimmy choo shoes
pandora jewelry
tiffany and co outlet
longchamp sale
purs jerseys
fit flops
air max shoes
20170817yuanyuan

Unknown said...

20180412xiaoke
birkenstock outlet
louis vuitton outlet store
pandora charms sale clearance
michael kors handbags
pandora outlet
replica rolex
ugg outlet
ugg boots clearance
christian louboutin shoes
oakley sunglasses sale

zzyytt said...

hermes bag
off white hoodie
yeezy boost 350
jordan 4
michael kors outlet
balenciaga sneakers
adidas stan smith women
pandora charms
links of london
kobe 11

Unknown said...

nike cortez women
nike air force 1 low
birkin bag
michael kors outlet
timberland outlet
hogan outlet online
nike mercurial vapor
kayno
adidas ultra boost 3.0
adidas yeezy