how to call static block in custom module template phtml file? - magento2

I want to call magento 2 admin static block in my custom module template phtml file. Anybody have idea? how can i do this task ?
below code working in theme phtml file but not working in my custom module phtml file.
<?php echo $block->getLayout()->
createBlock('Magento\Cms\Block\Block')->
setBlockId('login_register_text_2')->toHtml();?>

Use the below code snippet if you want to show CMS Static Block in any template in Magento 2
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('your_block_identifier')
->toHtml();

Related

Custom Helper Class not found in Prestashop module

I created a helper class in prestashop 1.6 module, in the override directory. I included the file in main module file but the class is not found in tpl files. I need it there to call one static method from smarty template.
Any ideas with this?
Thanks.

includeJsFiles not working in fluid ViewHelper in TYPO3

I need to add a custom js file in my backend module of TYPO3 v7.6 extension.I added the following code in my layout
<f:be.container includeJsFiles="{0:'{f:uri.resource(path:\'Js/Main.js\')}'}">
<!------------ Contents ------------>
</f:be.container>
No error but the js file is not included in page source.Any other method is there to implement my requirement?
I would assume the path to the JS-file is wrong.
With your declaration it is expected to be EXT:your_extension/Resources/Public/Js/Main.js in your extension (as statet in the core sources).
But when in doubt I would try some other pathes. (full references)

ext news: How can make the category option mandatory?

Is there a way to make the categories mandatory for the editor?
If not, what is a useful workaround in the class?
In this case I'm in a linkhandler class.
If the category is empty, how can I echo an error message which does not end in complete whitescreen in frontend (or even better be).
Is there an example for such an error message call?
TYPO3 7.6.10
news 4.3.0
In your sitepackage extension or any extension which is loaded after news, create the file Configuration/TCA/Overrides/tx_news_domain_model_news.php with the following content
<?php
defined('TYPO3_MODE') or die();
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['categories']['config']['minitems'] = 1;
If you want to show a message in the backend, a little bit more work would be required. In a hook of the DataHandler you could check the record after saving and add a flash message.

Phpfox Register Page Plugin Call

Can someone please explain this piece of code works in phpfox {plugin call='user.template_default_block_register_step2_7'}
Thanks in advance.
plugins are works in phpfox as a hook.
to add your custom code with in default phpfox system without changing any file we used plugin.
{plugin call='user.template_default_block_register_step2_7'}
to use this plugin you must create a file name user.template_default_block_register_step2_7.php
in any module even in your custom module.
what ever you write in this file it's automatically added where this plugin call.
you can add multiple plugin with same name in different module.
plugin file path
module_name/include/plugin/
It will include a block file in the following location,that block file has the registration page.
www/projectname/Module/user/template/default/block/register/step2.html

url for an action of a controller in zend framework

I am trying to learning Zend framework. For that I have installed NetBeans IDE and download zend framework's library. I have created one small application by NetBeans IDE and place the zend framework's library under library folder.
Under Controller folder, in IndexController.php file, I have written one action called indexAction() and there I write simply $this->view->assign('title', 'Hello, World!');.
Under views/scripts/index folder create one file called index.phtml and there I have written out <h1><?php echo $this->escape($this->title); ?></h1>.
My main folder name is phpproject1 and under that I have created all other folders like application, library,public.
Now please suggest me how to open that action in browser?
e.g. - In codeigniter it is like : localhost://project_name/index.php/controller_name/action_name
Thanks in advance.
I assume your installation is correct and you didn't configure any route. try to adapte this to your case.
http://lcalhost/[project_Name]/public/[Module_name]/[Controller_name]/[action_name]
in case you dont have Module;
http://lcalhost/[project_Name]/public/[Controller_name]/[action_name]