how to check which controller is calling pthml page in php - 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).

Related

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

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.

Custom Page Template VS Plugin VS Shortcode refer to function

I need to create a form that will be called many times through application .
below is the steps i did :
1- Create a form.php page and place it in my child theme folder.
C:\wamp\www\test\wp-content\themes\designfolio-child
i wrote the below code at the top of the page
<?php /* Template Name: Hercal Template */ ?>
and then i write my form code.
2-This page calls another PHP files and Jquery file , i place those file in
C:\wamp\www\test
3- I create a wordpress page and select a template option 'Hercal Template' ,
The page run now ,form loaded and working fine but i have some issue that i need to understand.
1-What about security , is it secure to place files and database connection to test folder directly ?
2-How can i call my form inside other pages ?
3-the above steps enables me to create a template page , so what is the difference between template page , plugin , short code that refer a function ???
I mean :
when i create a plugin , i can call it anywhere by using function name.
when i create a function,place it into wp-content and create shortcode for it , i can call it anywhere by using shortcode .
so what is the difference between them , i have conflict between (page template,plugin,shortcode).
Thanks
You should use shortcode to display form.
if you will use template than you can't put extra content/design for multiple places.
if you will use function than you have to call that in your page or you need to physically edit template file.
if you will use your form as shortcode than you can access/call it anywhere in your page/post/custom post and place it on anywhere between the div, paragraph etc.
Even you can access it on php file as well
I suggest you to use short code

Yii: Where does $this->menu filled with values?

Gii created a CRUD menu called operations. If you go to column2.php you will see this code.
$this->widget('zii.widgets.CMenu', array(
'items'=>$this->menu,
'htmlOptions'=>array('class'=>'operations'),
For some reason I want to edit above menu. I wonder where does $this->menu is filled with values which is defined in components/controller.php. I looked at every controller's code but couldn't find anything.
The menu is filled in view file (create.php, update.php, view.php, etc)
For some reason I want to edit above menu
What exactly you wanna do? If you want to change the way it's behave, you should try the CMenu.php file, located at /yii/framework/zii/widgets/

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

Drupal View (Page) vs Taxonomy

I have the following problem:
I use taxonomys (tx) as tags. They can be added when the node is created. So I don't know how many tx I have or what ID they have.
The path of the tx is like the following:
/foo/element1
/foo/element2
/foo/element3
...
The secound element is the tx.
Now I want to use a view (page) to handle the tx-path:
/foo/%
The problem is, when I open a path like the one on top I see the theme of the node-taxonomy.tpl.php but not the style I set in the view.
Whenever I open a path in the form (/foo/not-a-tx) I can see the output of the view.
Could someone give me a hint how to get out the view output but not the tx-output?
Thanks
Sebastian
I solved the problem with this way:
I use a view block (not a page)
I added a new output area in my ,info file
I use this way to show only the vocab
I show the block in the new area online bei foo/*
It works Okay for me.
Thx to every one.
Do you want to get rid of the taxonomy pages completely?
If so, you can use a hook_menu_alter() and unset the taxonomy page.
EX.
hook_menu_alter(&$items) {
unset($items['taxonomy/term/%taxonomy_term']);
}
You'd have to look at the $items array to pinpoint the name of the registered menu path, but I think this is it.
This will remove the taxonomy page for all vocabularies however.
Actually you need to make a view to override the internal drupal path of the taxonomy term page: taxonomy/term/% (where % is the taxonomy id) and not the aliased path, which in your case is foo/%
[Optional but saves work: There is already an example view that is bundled with Drupal that implements the taxonomy view. Go to Views > List and you will see the the view is greyed out and it is called
Default Node view: taxonomy_term (default)
All you need to do is enable it and modify it to your needs]
Don't worry about the aliases. You can define your URL pattern at /admin/build/path/pathauto (make sure pathauto module is enabled. You can download it at http://drupal.org/project/pathauto ). In your case the pattern would be foo/[cat] where [cat] is a token for category. Make sure you enter this pattern under Taxonomy Term paths in the pathauto automated alias settings.

Categories