how to refer one .phtml in the other views in Zend - zend-framework

am new in Zend framework.
I have one .phtml file, includes menus section. i need to add that .phtml file in to the views i.e views/scripts/index.phtml page.
how can refer that
please advice
thanks in advance

You can use the render helper:
<?=$this->render('menu.phtml')?>
If you want to pass specific variables to the rendered script, use the partial helper:
<?=$this->partial('menu.phtml', array("varname" => "value"))?>
The menu.phtml file must be in the search path, which usually is the path to the current module's scripts directory ( view/scripts ). You can either place the menu.phtml file in this directory, or add a directory to the search path using the addScriptPath() method on the view object.

Try this
echo $this->partial('path/file.phtml', 'ModuleName')

Related

Where must finisher files (for powermail finisher) be located?

I am currently trying to add a finisher to my powerplay form.
The target is to delete all elements in a specific folder after the form is submited.
I currently use :
this tutorial
I first put this into my setup.txt
plugin.tx_powermail.settings.setup {
finishers {
1 {
class = Vendor\Ext\Finisher\DoSomethingFinisher
}
}
}
at this location: ftp://ftpIP/typo3cms/pagename/typo3conf/ext/powermail/Configuration/TypoScript/Main/setup.txt
Now i should create a PHP-File:
Add a php-file DoSomethingFinisher.php and extend your class with the AbstractFinisher from powermail:
But where shuld I place that PHP File? In the same place as the setup.txt?
Hope someone can help. Thank you very much.
Thomas
That question is related to TYPO3 autoloading and not to powermail. If you want to add PHP-Files to your TYPO3, you should use an extension.
There are some manuals how to get the autoloading to work with your PHP-Files (see https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Autoloading/Index.html).
You shouldn't modify the files in the folder powermail, otherwise you will be in trouble when you want to update the extension. Instead, create a new extension with extension_builder or take powermailextended and modify that extension.
Assuming you use powermailextended:
If you call the Finisher In2code\Powermailextended\Finisher\MyFinisher, then it needs to go in EXT:powermailextend\Classes\Finisher\MyFinisher - this is how Typo3 autoloads the PHP files.

TYPO3: No template was found. View could not be resolved for action

I'm experimenting a bit with TYPO3 backend modules and I'm trying to get a view when I click my module in the left menu in the backend. However when I click this I get the following message:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "list" in class "MyVendor\MyModule\Controller\ConnectionController".
I have the view for the list action in the folder Resources/Private/Backend/Templates/Connection and the file is called List.html (uppercamelcase)
I'm using TYPO3 version 7.6.15 and I made this module with the extension builder.
Any help would be appreciated.
Some possible reasons for this (or similar) errors:
1. Forgetting to include the TypoScript static templates
see Documentation: Include TypoScript from extensions
Choose WEB > Template module (in Module menu)
Select your start (root) page (in page tree)
Select Info / Modify (in Docheader)
Choose Edit the whole template record
Choose tab Includes
Select your extension under Available Items
This will activate the TypoScript under Configuration/TypoScript
2. Wrong path
The Template paths set via TypoScript must match the available template paths in the filesystem.
Usually, the default path is:
Resources/Private/Templates (for frontend plugins)
or
Resources/Private/Backend/Templates (for backend modules)
This must have been set correctly via TypoScript. For example:
Configuration/TypoScript/setup.typoscript:
# Module configuration
module.tx_myexample_web_myexamplelist {
view {
templateRootPaths.0 = EXT:myexample/Resources/Private/Backend/Templates/
...
module. is for backend modules
if you are working with frontend plugins, use plugin. instead of module.
the correct file ending for TypoScript is .typoscript since TYPO3 8 and no longer .ts or .txt. For version 7, it is correct to use .ts.
3. Incorrect filenames
Make sure that the name of the Controller matches the name of the subdirectory in the Templates directory. The name of the template file is capitalized.
Controller/SomeController.php: listAction()
matches
Resources/Private/Backend/Templates/Some/List.html
Where to define the TS:
either as described above e.g. in Configuration/TypoScript setup.typoscript (and load this via static include).
The file ext_typoscript_setup.typoscript in the extension root can be used to setup TypoScript independent of page-tree and template-records. This will be included in the setup section of all TypoScript templates. but also consider the warning in the documentation.
Load TypoScript or TypoScript files directly in the extension with functions from ExtensionManagementUtility
You can also change your template root path (the relative path from where the extension takes the tempaltes):
go to the
setup.ts
file (or setup.txt file; depends on personal preferences and local configuration) and add the following line
plugin.tx_myslider.view.templateRootPath = EXT:path/to/custom/directory/
for example it could look like this:
EXT:slider/Resources/Private/Templates/myAwesomeFolder/
NOTE: slider is just a placeholder. You can simply replace it with your extension name
Add your extension to the website node. Until you add it, the setup.ts won't work.

CSS file in same view/scripts folder as phtml file

I have a CSS file that is in the same view/scripts folder as the phtml file that will use it. What is the correct parameter for $this->headLink()->appendStylesheet() for such a file?
Your css file must be accessible in public directory or public subdirectory like public/css/your_css_file.css
In your view, you can do something like this:
$this->headLink()->appendStylesheet($this->baseUrl() .'/css/your_css_file.css');
Normally your CSS file should be accessible publicly (within the public folder).
However, if you still want to leave it there (you will have performance issues especially if your file is large) just do so within your view file
<?php
$this->headStyle()->captureStart();
echo $this->partial('css-file.css');
$this->headStyle()->captureEnd();
?>
This will allow your file contents to be output, captured and then "injected" in the appropriate place in the layout.
Hope it helps

Zend framework - check if view exists and not exists use another path?

The default view path is view/scripts while i've another view/abc/scripts so for my default system it will use the default path while abc system use the abc path.
I have layout plugin to set it from bootstrap so it will see either one of the path.
But I just noticed that for abc system I may have view exactly the same from default. I can copy the file to abc folder but then I will have duplicate file and the content is exactly the same.
So I'm wondering if there's a way I can put in some code in one place other than controller(instead of every controller or one controller while other extends it) so if the view file not exists then it will look at the default path for the file?
You can add multiple paths in bootstrap
protected function _initView(){
$view = new Zend_View();
$view->addScriptPath(APPLICATION_PATH . 'path/to/path1');
$view->addScriptPath(APPLICATION_PATH . 'path/to/path2');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
return $view;
}
I think that it is simple to use file_exists function.

poEdit not creating source files

I am using poedit with zend_translate.
I have done everything required in zend. I have created some sample code in zend view files
$this->translate("Hello");
I have then created a new catalog in poedit.
I specified the initial settings (like base directory, translation function)
I edited php parser tab:
a) *.php to *.php;*.phtml
b) adding '-L php'
Then also its not getting any strings.
Anyone has any idea what i am doing wrong.
Under catalog settings, go to "Keywords" and add "translate" — that should fix it.