Mandrill is not replace merge tag content in html template - php

Mandrill API Logs --
"subject": "Valentine’s Day special offer. Additional 10% off* on select categories! View exclusive online offer",
"from_email": "habits#zip.in",
"from_name": "zipp",
"to": [
{
"email": "xyza_123#gmail.com",
"name": "venk",
"type": "to"
}
],
"merge": true,
"merge_vars": [
{
"rcpt": "xyza_123#gmail.com",
"vars": [
{
"name": "UNSUB",
"content": "http://zyr.com/unsubscribe/GYT786HHG"
},
{
"name": "FirstName",
"content": "venk"
}
]
}
],
"async": false,
"ip_pool": null,
"send_at": null,
And when I click on the unsubscriber link in the template, it takes me to the url http://*|unsub|*. Mandrill is not replacing |UNSUB| with http://zyr.com/unsubscribe/GYT&786HHG. Please help me . I spent a lot of time on it, but am unable to solve it
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;" class="mcnTextContentContainer">
<tbody><tr>
<td valign="top" class="mcnTextContent" style="padding-top:9px; padding-right: 18px; padding-bottom: 9px; padding-left: 18px;">
You can unsubscribe<br>
<br>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody>
</table>

There's no need to pass in UNSUB as a merge variable. Mandrill takes care of all of that for you. UNSUB is a reserved merge tag too, which is why it's not being replaced with the value you pass in your API call.
So in your API call, remove the merge var altogether:
{
"name": "UNSUB",
"content": "http://zyr.com/unsubscribe/GYT786HHG"
},
And in your HTML template, use this instead:
You can unsubscribe<br>

Related

filter json data in a table when checkbox clicked

I want to filter table rows when I clicked checkbox (high, low, med, small large..)from json data according to filtered value.
I am trying here filter table rows according to filter values in the Solutions.
If I clicked High checkbox, it should show only the solution of filtered value (281) ie, SolutionID(abc1234 and abc1235).
Someone can help how to achieve the filter function for json data.
I have done this with MySql and javascript with php whereclause.
Checkboxes
<input type="checkbox" id="High" name="High" onclick="applyFilter()">
<label for="High">High</label>
<input type="checkbox" id="Medium" name="Medium" onclick="applyFilter()">
<label for="Medium">Medium</label>
<input type="checkbox" id="Low" name="Low" onclick="applyFilter()">
<label for="Low">Low</label>
json data...
Nested json data have the Filter types and values. Also has solutions I can display solutions in a table. I want to filter these solutions when I clicked checkbox, it should display only particular solutions which has filter value like 281, 283 only.
{
"Program": [
{
"Id": 2,
"Name": "Solution",
"FilterTypes": [
{
"Id": 10,
"Title": "Case",
"FilterValues": [
{
"Id": 281,
"Value": "High"
},
{
"Id": 282,
"Value": "Mid"
},
{
"Id": 283,
"Value": "Low"
}
]
},
{
"Id": 10,
"Title": "Case",
"FilterValues": [
{
"Id": 284,
"Value": "Micro"
},
{
"Id": 285,
"Value": "Small"
},
{
"Id": 286,
"Value": "Large"
}
]
}
],
"Sets": [
{
"Id": 324,
"Name": "xyz",
"Solutions": [
{
"Id": 100,
"SolutionId": "abc1234",
"Title": "XYZ Solution1",
"Published": "Tested Solution1",
"Info": "This is for perticular Solution1",
"FilterValues": [
{
"FilterValueId": 281
},
{
"FilterValueId": 283
},
{
"FilterValueId": 286
}
]
},
{
"Id": 101,
"SolutionId": "abc1235",
"Title": "XYZ Solution2",
"Published": "Tested Solution2",
"Info": "This is for perticular Solution2",
"FilterValues": [
{
"FilterValueId": 282
}
]
},
{
"Id": 102,
"SolutionId": "abc1236",
"Title": "XYZ Solution3",
"Published": "Tested Solution3",
"Info": "This is for perticular Solution3",
"FilterValues": [
{
"FilterValueId": 281
},
{
"FilterValueId": 282
}
{
"FilterValueId": 286
}
]
}
]
}
]
}
]
}
Table
Table is displaying all the solutions.
<table style="border: 5px solid; padding: 0px; width: auto;" border="1">
<thead>
<tr style="background-color: #425462; color: white">
<th style="text-align: center">Solution ID</th>
<th style="text-align: center">Published</th>
<th style="text-align: center; width:10%">Info</th>
</tr>
</thead>
<?php if(count($decoded) !=0){
foreach($decoded['Programs']['Sets']['Solutions'] as $item){
?>
<tr class="solnrow1" style="background-color:;text-align: center; width: auto">
<td style="text-align: left"><?= $item['SolutionId']?></td>
<td style="text-align: left"><?= $item['Published']?></td>
<td style="text-align: left"><?= $item['Info']?></td>
</tr>
<?php
}
}
?>

Record is not loading to the Datatable using php ajax

i am creating the simple crud system using php. when i load the to the datatable data is not loading.when i show the error on console Uncaught TypeError: Cannot read property 'length' of undefined
i am tring to solve out this problem since yesterday but i couldn't
Table
<table id="tbl-category" class="table table-responsive table-bordered" cellspacing="0"
width="100%">
<caption> Products</caption>
<thead>
<tr>
<th>Patient No</th>
<th>Name</th>
<th>Phone</th>
<th>Address</th>
</tr>
</table>
jQuery
function get_all() {
$('#tbl-category').dataTable().fnDestroy();
var oTable = $('#tbl-category').DataTable({
"ajax": {
"url": 'all_category.php',
"type": "get",
"datatype": "json"
},
"columns": [
{ "data": "patientno" },
{ "data": "name" },
{ "data": "phone" },
{ "data": "address" },
]
})
}
all_category.php Page
<?php
include("db.php");
$stmt = $conn->prepare("select patientno,name,phone,address from patient order by patientno DESC ");
if ($stmt->execute()) {
$stmt->bind_result($patientno,$name,$phone,$address);
while ( $stmt->fetch() ) {
$output[] = array ("patientno"=>$patientno, "name"=>$name,"phone"=>$phone,"address"=>$address);
}
echo json_encode( $output );
}
$stmt->close();

How to store the following JSON result into HTML table?

{
"total_count":3,
"offset":2,
"limit":2,
"notifications":
[
{
"id":"481a2734-6b7d-11e4-a6ea-4b53294fa671",
"successful":15,
"failed":1,
"converted":3,
"remaining":0,
"queued_at":1415914655,
"send_after":1415914655,
"canceled": false,
"url": "https://yourWebsiteToOpen.com",
"data":null,
"headings":{
"en":"English and default langauge heading",
"es":"Spanish language heading"
},
"contents":{
"en":"English and default content",
"es":"Hola"
}
},
{
"id":"b6b326a8-40aa-13e5-b91b-bf8bc3fa26f7",
"successful":5,
"failed":2,
"converted":0,
"remaining":0,
"queued_at":1415915123,
"send_after":1415915123,
"canceled": false,
"url": nil,
"data":{
"foo":"bar",
"your":"custom metadata"
},
"headings":{
"en":"English and default langauge heading",
"es":"Spanish language heading"
},
"contents":{
"en":"English and default content",
"es":"Hola"
}
}
]
}
Assuming you are wanting to display your JSON data within a HTML table, here is a basic example:
<?php
$json=<<<JSON
[
{
"name": "foo",
"age": 23,
"mood": "happy"
},
{
"name": "bar",
"age": 38,
"mood": "sad"
}
]
JSON;
$people = json_decode($json);
?>
<html>
<table>
<thead>
<tr><th>Name</th><th>Age</th><th>Mood</th></tr>
</thead>
<tbody>
<?php foreach($people as $person): ?>
<tr>
<td><?= $person->name; ?></td>
<td><?= $person->age; ?></td>
<td><?= $person->mood; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</html>
You can easily do it by using AppML, here is a tutorial which will get you started quickly.

multidimensional array in angular have issue

What is the issue in my code?
return array is
{"records":
[{"Status":"1",
"Date":"2017-07-14 10:46:33",
"Email":"cy#gmail.com","Company":"Inc.",
"Model":"Model 8081 A","Animation":"Walk, Turn Around","id":"1",
"Note":"This is a new request for model with animation.",
"Attachment":
"[{'url':'request/31a.jpg','name':'a.jpg'},{'url':'request/42Light.png','name':'Light.png'}]"
}]
}
And HTML code is
<tr ng-repeat="x in records">
<td>{{x.Status}}</td>
<td>{{x.Date}}</td>
<td>{{x.Email}}</td>
<td>{{x.Company}}</td>
<td>{{x.Model}}</td>
<td>{{x.Animation}}</td>
<td>{{x.Note}}</td>
<td>
<table>
<tr ng-repeat="lnk in x.Attachment">
<td>{{lnk.url}}</td>
<td>{{lnk.name}}</td>
</tr>
</table>
</td>
</tr>
lnk.url and lnk.name print nothing.
Error in console is [ngRepeat:dupes]
Your attachment is not an array, it is a string. Your return array should be like this:
{
"records": [{
"Status": "1",
"Date": "2017-07-14 10:46:33",
"Email": "cy#gmail.com",
"Company": "Inc.",
"Model": "Model 8081 A",
"Animation": "Walk, Turn Around",
"id": "1",
"Note": "This is a new request for model with animation.",
"Attachment": [{
"url": "request/31a.jpg",
"name": "a.jpg"
}, {
"url": "request/42Light.png",
"name": "Light.png"
}]
}]
}
(Notice removed quotes in Attachment).
So you should convert Attachment with JSON.parse() function in your controller.
Attachment is a string not an array. convert it to an array and it will l work
angular.module("app",[])
.controller("ctrl",function($scope){
$scope.records = [
{
"Status":"1",
"Date":"2017-07-14 10:46:33",
"Email":"cy#gmail.com",
"Company":"Inc.",
"Model":"Model 8081 A",
"Animation":"Walk, Turn Around",
"id":"1",
"Note":"This is a new request for model with animation.",
"Attachment":[{'url':'request/31a.jpg','name':'a.jpg'},{'url':'request/42Light.png','name':'Light.png'}]
}
]
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<table>
<tr ng-repeat="x in records">
<td>{{x.Status}}</td>
<td>{{x.Date}}</td>
<td>{{x.Email}}</td>
<td>{{x.Company}}</td>
<td>{{x.Model}}</td>
<td>{{x.Animation}}</td>
<td>{{x.Note}}</td>
<td>
<table>
<tr ng-repeat="lnk in x.Attachment">
<td>{{lnk.url}}</td>
<td>{{lnk.name}}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>

DataTable AjaxSource

I'm going straight to the point here.
what I am trying to accomplish is to populate the table using ajax.
this gives me jquery.dataTables.min.js:39 Uncaught TypeError: Cannot read property 'length' of undefined error.
here's my code:
my php code:
public function pending_data(){
$result = $this->ticketing_m->get_pending_tickets();
echo json_encode($result);
}
JQUERY
var datatable = $("#datatable");
datatable.DataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": datatable.data('url')
});
HTML
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%" data-url="<?php echo site_url(array("dashboard","pending_data")); ?>">
<thead>
<tr>
<th>Ticket Number</th>
<th>Subject</th>
<th>From</th>
<th>Date Created</th>
</tr>
</thead>
</table>
QUERY RESULT
First off, you should probably set bServerSide to false. If it is true you need to actually read the request parameters, do server side processing and structure your return data as outlined in the Server-side processing documentation. Since you are doing none of those things here I'm assuming you simply want to use Ajax sourced data and let the DataTables javascript handle the table processing
Next, structure your json with the table data inside data as shown here in example #2. Your json should look something like this:
{
"data": [
{
"date_created": "2017-06-13 13:57:24",
"full_name": "John Doe",
"subject": "Test",
"ticket_number": "Ticket 1234"
},
...
]
}
To accomplish this you might do something as simple as this in the response from pending_data():
echo json_encode(array('data' => $result));
Also, the way you have your DataTables properties set up here looks like you are either using a very old version or an outdated syntax. I'd suggest installing the latest version and using up to date code. You can get all the downloads and examples you might need at: https://datatables.net
I think your ajax source has 4 columns.
But you have 5 columns in < thead >.
Pls remove one tag in < thead >.
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%" data-url="<?php echo site_url(array("dashboard","pending_data")); ?>">
<thead>
<tr>
<th>Ticket Number</th>
<th>Subject</th>
<th>From</th>
<th>Date Created</th>
</tr>
</thead>
</table>
var oTable = $('#datatable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "${pageContext.request.contextPath}/",
"aoColumns" : [
{ "mData": "Ticket Numbe" },
{ "mData": "Subject" },
{ "mData": "From" },
{ "mData": "Date Created" }
]
});
I don't get the exact problem.This may help..
Do something like that also use data type https://datatables.net/examples/server_side/jsonp.html
"processing": true,
"serverSide": true,
"ajax": {
"url": "scripts/jsonp.php",
"dataType": "jsonp"
}
Use it like:
var url = 'http://www.json-generator.com/api/json/get/cbEfqLwFaq?indent=2';
var table = $('#example').DataTable({
'processing': true,
'serverSide': true,
'ajax': {
type: 'POST',
'url': url,
'data': function (d) {
console.log(d.order);
return JSON.stringify( d );
}
}
});
Working Fiddle

Categories