Views not being displayed in a non-default configuration using Phalcon - php

I generated a project using, phalcon tools. In the config.php I changes view to:
'viewsDir' => APP_PATH . '/views/test/',
I have created two controllers: ExampleController and TestController
I have links pointing to http://example.com/test and http://example.com/test
In the views folder I have placed 2 files, one in views/test/example/example.phtml and another in views/test/test/test.phtml when I try to go to the links I get a blank page, if I move the phtml files in folder views/test/ the view that is loaded is the index.phml no matter which of the 2 url's I go to (this is the page that displays the 2 links above). If I echo out from the controllers this is displayed so the controllers are being accessed just the view are not being displayed. Please can someone advise? (Nb. If I use the default view configuration, then the views are being displayed)

You should place an index.phtml file in both directories. Thats the page that's loaded once you point to the respective controller. If you want it to load e.g example.phtml, you have to create an action called exampleAction in ExampleController. Then call it via http://example.com/example/example.

Related

how to load my default controller in codeigniter using bootstrap?

i have a view with bootstrap template which is embedded at my view/reportlist.php (localhost/Project/index.php). the problem is that every time i perform a CRUD, well codeigniter reroutes me to deffirent uri. example, when i edit a report from my list, i will be redirected to my view/reportlist.php (/Project/index.php/report/edit). then my bootstrap template is ruined. i need to go back to the /Project/index.php to load back everything up. please if you know, post some ideas, ive been like this for days now, i cant find a relevant answer.
there is no relation between codeigniter route and bootstrap. you can set you default controller in line 41 in: application > config > route.php file.
on ther other hand you can set you base_url in line 17 in: application > config > config.php by this:
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('#/+$#','',dirname($_SERVER['SCRIPT_NAME'])).'/';
I'm sure that you have call again the list view in you edit method in report controller :D .
if you want to avoid index.php from you url then you can modify code in your .htdocs files:
In your form action attribute specify a route: <?php echo base_url('/someRoute'); ?>, and in routes.php map it to some specific controller: $route['someRoute'] = 'home/someRoute';, from this controller load your desired view.

how to check which controller is calling pthml page in php

I have a page in UI that has some data set in it(a textbox) .
Now i need to check where this data is set from ?
My steps were :
1. Right click on elemnt in the browser.
2. Select "inspect element" .
3. From there, I managed to find the PHTML page that is actaully displaying the data I am searching for.
In the PHTML page, "$this->resources" does the job of holding data.
Now the question is , how can i find where this data is being SET ?
Obviously a controller will do that. So i had searched for "$this->view->resources" in my project to find the respective controller, but it didn't fetched me the exact result.
Any other tips other than what I am trying to do .
P.S I am using PHP ZEND framework.
Thanks for reading .
Regards,
Sagar
I think, you want get Controller and Action names?
Using:
Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
Zend_Controller_Front::getInstance()->getRequest()->getActionName();
In the same folder where 'view' folder with PHTML temlates is located, should be 'src' folder.
In it should be folder with the same name as your module.
In this folder should be the controller, with particular method (action) corresponding to your PHTML template. CamelCase in the action name maps to hyphenation in the template file name (CamelCaseAction => camel-case.phtml).

Preventing a specific CSS file from getting loaded in Yii

I am coding in Yii.
I have registered the main.css file in my main.php layout file like so :
Yii::app()->clientScript->registerCssFile($this->assetsBase.'/css/main.css');
Now this script is being registered in all the pages. However, say I don't want that script to be registered on a specific page.
I know that using :
Yii::app()->clientScript->reset();
would remove all the CSS files, however I want only few CSS files to be unregistered.
Is there a way to do it?
You can use the scriptMap property of CClientScript in your specific view, passing false for the particular script/css file's key that you don't want to be rendered. From the doc:
The array keys are script file names (without directory part) and the array values are the corresponding URLs. If an array value is false, the corresponding script file will not be rendered.
For example, in say views/site/pages/about.php:
Yii::app()->clientScript->scriptMap = array(
'main.css' => false
);
to disable the inclusion of main.css registered with registerCssFile.
The scriptMap can also be used for controlling the rendering of js script files.
I would suggest either:
Using a separate layout for that page like main_no-css.php
or
Adding a condition before registering the script (like if controller != xxx and action != yyy), but this would cause the condition to be checked on every other page.
I would definitely go for a separate layout.

Theming and layout in yii framework

I am a newbie in Yii Framework and creating a CRM which is module based.
Using different tutorials I am able to create my own theme, but now I am stucked at one point.
In my theme, the upper <nav> and left <nav> remains the same throughout the app, until user is logged in. That's why I made it a part of my main.php, but in the login page there are no buttons to show, just simple login form with 2 textfields.
How can I implement this form in my application using custom themes?
I have tried to define a layout in that particular action but not succeeded. Any help would be appreciated.
Using a custom layout for your view is the right way to go.
You can either set the layout in the controller action or in the view.
$this->layout = "//layouts/mylayout";
Note that the default layouts column1.php and column2.php also use the main.php layout file.
Try this step by step :
Create New theme
You can create a new theme and add this to the directory
Application_Root/themes.
Look at the themes/classic directory to get an an idea of the structure of the directory.
The important file (at this stage) is :-
Application_Root/themes/views/layouts/main.php
Customise your theme contents
Copy the css, image, js files etc to the correct directory and change the main.php file to your liking. For example, if your main.php says
<link href="css/mystyle.css" rel="stylesheet">
Then you will have a file
Application_Root/css/mystyle.css
Create the content placeholder.
Somewhere in your main.php, there will be a placeholder for dynamic text, which is specified by.
<?php echo $content; ?>
Tell yii to use the theme.
Change the file Application_Root/protected/config/main.php by adding the following line just before the last line (containing the closing bracket).
'theme'=>'surveyhub'
Create the layout placeholders.
Create an HTML segment that will be written into the $contents portion of main.php. Call it for example one_column.php. The file path will therefore be Application_Root/themes/views/layouts/one_column.php In that file, where you want the dynamic text to be placed, create a placeholder.
<?php echo $content; ?>
Tell Yii to use the layout.
In the file Application_Root/protected/components/Controller.php, add or modify the layout variable to read :
public $layout='//layouts/one_column.php';
Refresh the page

Front-end phtml template form doesn't connect to controller.php file

The web system which I'm working on right now, has a add.phtml (in views folder) form, which contain normal form elements and pageController.php (in Controller folder) file which has function to be connected when user hit "add page" button on the form. The codes goes like this.
on add.phtml file,
input type = "submit" value ="Add Page"
on pageController.php file,
function insertAction(){
}
For some reason these two doesn't connect now. Is anybody have any idea why this doesn't work or what should I check on this kind of a problem. The web system on zend framewok. I really appreciate if someone can help me.
Google for Zend beginning tutorials.
Essentially your pageController is looking for a phtml file in
views/scripts/page (note page is the same name as the 'page' in pageController) directory and is expecting a phtml file insert.phtml, this file's root name corresponds to the action defined in the controller, see insertAction.
sic.
class doodahController extends Zend_Controller{
public function campdownAction(){
}
//..more stuff
}
Directory structure
application
controllers
doodahController
views
scripts
doodah
campdown.phtml

Categories