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);
Related
Is there a way to show the sitemap at 404 page in cs-cart(4.5.x)? What I did is copied the sitemap.tpl code inside the 404.tpl, but it just renders empty container without links. I think the sitemap controller should be called somehow to populate the sitemap but I have no idea how to do it. May be u can give me any hint?
So to call sitemap controller when the 404 renders I had to hook up fn_control function by using before_dispatch(http://www.cs-cart.com/api#312352) and to copy the sitemap controller code inside that hook function. That's all.
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\Block')->setBlockId('your_block_id')->toHtml();
I have the folliwng file:
app/design/frontend/default/site/template/checkout/cart/cartheader.phtml
I want to load this in via ajax, so that when the cart is updated, we can trigger an ajax call to get the contents of this file and update the page on the fly.
Does anybody know how I can access this file via ajax or even just from my browser so I can see the contents?
Thank you
You need to create a new controller with methods from CartController.php this controller can be found in app/code/core/Mage/Checkout/controllers . The methods to add and remove items from cart should be changed to use ajax and return json. The json returned can have the session messages - global messages block and cart header block, maybe other blocks depending on all info you want to update.
app/design/frontend/default/site/template/checkout/cart/cartheader.phtml is from the enterprise theme and is the template for the block Mage_Checkout_Block_Cart_Sidebar. This template is set inside layout/checkout.xml
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topCart" template="checkout/cart/cartheader.phtml">...</block>
To get it from a controller you can add it to the layout xml of that controller, or use:
$this->loadLayout()->getLayout()->createBlock('checkout/cart_sidebar')->toHtml();
But inside Enterprise, this block already loads using ajax.
I'm fairly new to Magento and am setting up a new theme from scratch. I'm not using any of the standard Magento JS files until now and I've included jQuery and a js file for custom scripts.
Now I'm looking into recreating the Add To Cart functionality but standard wise this seems to call some js function which I do not have declared now (lacking the Magento JS files). I'd like to set it up on my own with an ordinary form submit.
Can anyone give me an example of how to execute the Add To Cart command for the product I'm currently viewing? Without the necessity of standard Magento JS files?
What Magento do for add to cart is it calls productAddToCartForm.submit function of javascript to validate all required field and if true then it submit product form.
So you can call your javascript method for form submit and add to cart.
Add to cart button comes from this file, so you can change onclick event here.
app\design\frontend\base\default\template\catalog\product\view\addtocart.phtml
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!