Unsubscribe link is not working in magento newsletter template - magento

I have created one newsletter template in my store ( magento based ) and have added following code to make unsubscribe link:
Follow this link to unsubscribe:
{{var subscriber.getUnsubscriptionLink()}}
But, when I tested it there was no link received in my email. I can see only "Follow this link to unsubscribe:" in my email but there is no link to unsubscribe this email.
Note: I have added this content under "Template Content" section.
Please help!
Thank you in advance!

In your Template.php file the getTemplateText function should look something similar to this;
public function getTemplateText()
{
if (!$this->getData('template_text') && !$this->getId()) {
$this->setData('template_text',
Mage::helper('newsletter')->
__('Follow this link to unsubscribe <!-- This tag is for unsubscribe link -->
<a href="{{var subscriber.getUnsubscriptionLink()}}">
{{var subscriber.getUnsubscriptionLink()}}</a>')
);
}
return $this->getData('template_text');
}
Is this what you are using? It could be that the tags have been removed.
You should also check what happens when the emails are sent to different mail clients, just to rule out local factors.

I know I am late here but still I want to share solution here.
I am using Magento 1.9.
To add newsletter unsubscribe link in newsletter template here are following steps:
Override the core file
/app/code/core/Mage/Newsletter/Model/Subscriber.php
by copy in local directory
/app/code/local/Mage/Newsletter/Model/Subscriber.php
Open in editor to edit the code and seacrh the function sendConfirmationSuccessEmail()
replace the code
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
$this->getEmail(),
$this->getName(),
array('subscriber'=>$this)
);
with this
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
$this->getEmail(),
$this->getName(),
array('subscriber'=>$this, 'unsubscribe' =>$this->getUnsubscriptionLink())
);
and place this code in email template where you want to use unsubscribe link:
Unsubscribe here
That's it!
Hope this helps someone.

Related

Check to see if a page is called via Ajax in Laravel

This is an extension from a post I made a few days ago: Change a page without refreshing - Laravel / Ajax
Basically, I'm trying to replicate the URL Structure of Soundcloud where you can click on a link, it'll load the content without refreshing the page however if you land directly on that page, it won't replicate design and effecitvely break.
I've been thinking of ways on how I can check in Laravel if the page is requested via Ajax or has been landed on without an Ajax call.
What's happening at the moment is that when I call the page, the view has a master template that's extended thus creating duplicate master templates on the one view.
I was thinking if I done something like
#if(!Request::ajax())
#extends('masterlayout')
#endif
It would work but tried and no luck.
Any help as always is greatly appreciated!
Thanks
Looks like #extends directive is always executed even in falsy if
You can add an empty layout and perform check like this:
#extends(Request::ajax()? 'layouts.empty' : 'layouts.master')
and you need add only this in layout empty.blade.php:
#yield('content')
or you can add ajax check in the master layout
#if(!Request::ajax())
// all layout code
#else
#yield('content')
#endif
You can check that in your controller action.
public function index(Request $request)
{
if($request->ajax()){
return "This is an AJAX call!";
}
return "Not an AJAX call...";
}
Thanks for all the answers, I eventually got this fixed by using #if(!Request::ajax()) on section that didn't need to be shown when the page was loaded via ajax.
Thank you again! :D

Load Magento module template

For a Magento module I need to load template file and let it replace the complete page. It is a XML file (but could also be any content whatsoever).
Generally speaking when
MYNS_MYMODULE_controllernameController is triggered and calls fooAction() I need to be able to display a clean site with the content from my template file.
Please let me know where to place the template file and how to tell Magento to load this file as a root template without anything else around.
Edit, to clarify it more:
For http://domain.tld/modulename/controller/action/
Where do I have to place template files and how should I reference them?
You could do it like this
$this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
$this->renderLayout();
or to set a custom response
//$file = myfile or html
$this->getResponse()->setBody($file);
$this->renderLayout();
Ideally your template should sit in /app/design/frontend/mypackage/mytheme/template/mytemplate.phtml
You should read Magento doc and Alan Storm Blog. Alan also wrote a book about Magento Layout: No Frills Magento Layout.
Your url: http://domain.tld/modulename/controller/action/
The modulename_controller_action Handle is created by combining the route name (modulename), Action Controller name (controller), and Action Controller Action Method (action) into a single string. This means each possible method on an Action Controller has a Handle associated with it.
In your layout xml handles this request:
<modulename_controller_action>
......
</modulename_controller_action>
Hope my suggestion is useful for you.

Breadcrumb in magento

I am to magento. I got breadcrumb in my static blocks by default. But In my dashboard page, it is not displaying.I have searched in Google but nothing works. Can anyone tell me how to add breadcrumb in my dashboard page.I want to display breadcrumb without using page.xml
Thanks in Advance.
Go to app\design\frontend\your-package\ your -theme\template\your-modulename\phtml-file and add the following code snippet as per your requirement
// to get breadcrumbs block
<?php $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
// add first item ‘'home'’ with link
$breadcrumbs->addCrumb(
'home',
array(
'label'=>$this->__('Home'),
'title'=>$this->__('Home'),
'link'=>Mage::getBaseUrl()
)
);
// add second item ‘'brands'’ without link
$breadcrumbs->addCrumb(
'brands',
array(
'label'=>$this->__('Brands'),
'title'=>$this->__('Brands')
)
);
echo $breadcrumbs->toHtml(); ?>
By default in magento breadcrumb not come for member account section. You can add breadcrumb using xml. Here is the blog post that explain complete steps:
http://www.douglasradburn.co.uk/adding-breadcrumbs-to-customer-account-pages-in-magento/
You can also use the below extension to add breadcrumb links:
http://www.magentocommerce.com/magento-connect/customer-account-breadcrumbs.html
You need to check its compatibility with latest version.

Magento: Empty Payment Html in Methods.phtml

I’ve got a problem with the payment methods for my checkout. When I reach the Checkout Step for the Payment Methods, the several options are displayed but I am getting no further Information to the Methods “Bank Payment” and “Cash on Delivery” when I click on the radio button.
It seems to me that getPaymentMethodFormHtml (checkout/onepage/payment/methods.phtml) is empty for these Methods. As a result of this issue, I am getting no information in the Order Confirmation Mail (like Bank Name, Cash on Delivery Fee).
Can anyone help me?
Your error should be in
/app/design/adminhtml/default/default/template/payment/form/[cc.phtml]
/app/design/frontend/default/default/template/payment/form/[cc.phtml]
You may need to take a look at each payment method to see the path for their template
e.g
<?php
class MagePal_CimPaymentPro_Block_Form_Payment extends Mage_Payment_Block_Form_Cc
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('magepal/cimpaymentpro/payment/form/cc.phtml');
}
Also, you may want to check to make sure you don't have any javascript error on that page.
You could also use Inspect Element in chrome/Firefox (or firebug) to see if the html is hidden by css

Magento creating new customer page

Ok i cant figure this out at all. I have searched and i cant find anything either. Whats the best way to add a new page to the account section. I am trying to integrate a support ticket system into a magento account page i.e. so the user must be logged in and registered to use this feature. i can get this to work using a cms page and custom page layout. but then how do i set this custom cms page to only work for logged in users?
Also doing it this way this is showing the category menu and not the account menu. How can i get the my account menu to show instead? or is there a better way of doing this? Im new to magento and im really stuck and cant figure this out so any help would be appreciated.
Im running magento 1.7.0.2 community edition.
If I understand you correctly, just check to see if the customer is logged in, but in order to use PHP you're going to have to use the teplating system and create a module, or generate your own "stand alone page" If you go the module route:
if ($this->helper('customer')->isLoggedIn()){
//show page contents or do whatever ..
}
else{
header( 'Location: http://www.yoursite.com/customer/account/login/' ) ;
}
is all you'll need. IF you go the stand alone route:
//LOAD MAGENTO
require_once 'YOUR_PATH_TO_MAGENTO/app/Mage.php';
umask(0);
Mage::app('YOUR_WEBSITE_CODE', 'website');
//GET SESSION DATA
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
$customer_data = Mage::getModel('customer/customer')->$session->id);
//CHECK IF LOGGED IN
if($session->isLoggedIn()){
echo 'Welcome ' . $customer_data->firstname . " " . $customer_data->lastname;
} else {
echo "Access Denied: Sorry, but this page is for registered members only.";
exit;
}
Hope that helps
For any action there is a controller and action function.
So for your new feature you define an action.Make sure this action value is in URL.
Now within your controller add this action function
myAction()
{
if ($this->helper('customer')->isLoggedIn()){
//show page contents or do whatever ..
}
else{
header( 'Location: http://www.yoursite.com/customer/account/login/' ) ;
}
}
Although both of the answers above might have sufficed for the question posted, just for a note, it is surely not the correct way to work with Magento, a better understanding of how this can be achieved in the way according to magento practices, I think this tutorial from Alan Stormis a great place, however there is some problem with the preDispatch method in that blog, for which I think it might be better alternative:
public function preDispatch() {
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->authenticate($this)) {
$this->setFlag('', 'no-dispatch', true);
}
}
Which I got from here.
In Alan's blog, If a customer is already logged in and try to go the custom account page, he is redirected to the homepage(It did in my case.)

Resources