php - yii2: How to load relative path,action,view ... in module -


i'm start working yii2.

------------- problem number 1: load view error ----------------- have site module sitecontroller , it's views.

actionindex(){     $this->render('index'); } 

it show error: view root_path/views/site/index.php not found (note: root_path driectory in local).

in init() function in root_path\modules\site\module.php file: added statement test: echo $this->getviewpath();

result: root_path\modules\site\views

i want ask: why not load index.php in /modules/site/views folder ??? (it load index.php in root_path\views folder not found view file)

------------- problem number 2: load action error --------------

when add root_path\modules\site\module.php file: yii::$app->setlayoutpath($this->getlayoutpath()); can load correct view actionindex. links view not working:

$menuitems = [     ['label' => 'about', 'url' => ['/site/about']] ] 

html generaated on front-end:

<a href="/site/about">about</a> 

why href '/site/about', want value "site/site/about"

to call 'about' link have create about.php in views/site , create function name must actionabout() in sitecontroller

in sitecontroller

public function actionaboute() { $this->render('about'); } 

in index.php

<?= html::a('about', ['value'=>url::to('index.php?r=site/about')]) ?> 

and load view problem check config file , cookievalidationkey once.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -