Magento set content in action - magento

I'm quite new to Magento
And I'm creating the payment module which redirects to PaymentController
I have redirectAction
And I need to solve a simple task:
I need to show the content from a .phtml file in
$this->loadLayout();
$cmsBlock = $this->getLayout()->createBlock('cms/block')->setBlockId('cms_block_fail');
$this->getLayout()->getBlock('content')->append($cmsBlock);
$this->renderLayout();
return $this;
And nothing is showing up
All I need is just to show some html in the main site layout

Use registry to pass data to template.
Create registry on controller and and display into phtml file.
check below link how to create registry:-
http://blog.chapagain.com.np/magento-how-to-set-and-get-registry/

Related

How to call Cms Block content and html in controller file back end magento2

I'm Working with magneto 2. I want to get cms block content in my custom module controller file.
I want to know to Get the my custom module controller file. i'm not able to do.
i have used code
echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml();
inside my controller but code is not working.
How can I do?
Try with below block code.
echo $this->_view->getLayout()->createBlock('Magento\Cms\Block\Bl‌​ock')->setBlockId('y‌​our_block_id')->toHt‌​ml();

Prestashop module admin panel with custom view

I need to know how to create a module on Prestashop with a custom view on admin. The documentation is very poor and I don't understand how to call a view with parameters passed by the controller. I'm using Prestashop version 1.6.
I already did these steps:
Created XML.
Created controller with constructor and install/uninstall.
Created table on DB and class.
Linked on admin menu my module.
When I go to my tab on admin panel I see a table with my db data. I need to load a custom tpl file where I can customize completely my page.
I have read so many guides and documentation (ufficial or not) but nothing clear.
Just follow the HTML and CSS in getCOntent() function in your main php file.
Whatever HTML and CSS return getContent() function will be view of your module in admin panel.
Just concentrate in getContent function of other existing module and you will get what you want.
I f you want to load a separate view than create it separate and load it in getContent() function.

Magento does not put category name in product url when generating google sitemap xml

How can I add category path to products' urls inside xml sitemap? I have tried to modify the following 2 files but nothing has changed. Which files should I modify?
\design\frontend\base\default\template\catalog\seo\sitemap.phtml
\code\core\Mage\Catalog\controllers\Seo\SitemapController.php
Thanks!
You shouldn't modify any files, but in a standard Magento system the file that generates the site map whose behavior you should seek to change through Magento class rewrites or additional Magento code is located in the following class/method
#File: app/code/core/Mage/Sitemap/Model/Sitemap.php
public function generateXml()
{
//...
}

Call Magento .phtml file via ajax

I have my custom magento plugin. I have the image slider in the product page. I want to call ths particular template(abc.phtml) file via ajax in the product page. Can somebody help me in this?
Thanks
Create such code in your controller (which will render AJAX call) action:
$html = Mage::getSingleton('core/layout')->createBlock('core/template')
->setTemplate('your_module/abc.phtml')->toHtml();
$this->getResponse()->setBody($html);

Block Method Calls in CMS Page

Is there any a way to call Block method calls in CMS page?
What I am trying to do is. I have a hyperlink in my CMS Page and I want to retrieve the email address of the customer to pass it as a get variable which another website will use.
e.g. In CMS page I have
(someother website link)
<a href="www.xyz.com?email=<?php $getCutomer->getEmail();?>&&name=<?php $getCutomer->getName();?>
I know we can't add php in CMS pages or block. I have just shown you as an example what I want to achieve.
So is there any way using XML or anything else?
Please Advise. Thanks
Yes as MagePsycho said, you will need to create phtml file for calling block method or getting dynamic data.
In .phtml file, it's simple just call $this->getCustomerEmail() or whatever method you wrote to get customer email.
Why can't you simply include the .phtml file in CMS page or Static block as:
{{block type="core/template" template="path/to/your-custom-template.phtml"}}
and you can now use any php code in that .phtml file.
Cheers!

Resources