Use Google static maps in email - google-maps-static-api

I am trying to map the below on Google static maps. however, the locations are not showing up when I use individual lat & log they work ... could you please help?
<img src = "https://maps.googleapis.com/maps/api/staticmap?&zoom=13&size=600x300&maptype=roadmap
&markers=color:blue%7Clabel:S%7C-21.1406555,149.1868439&markers=color:green%7Clabel:G%7C-23.8640118,151.2430725
&markers=color:red%7Clabel:C%7C-19.3205890,146.7620640
&key=AIzaSyAbiWesdtKxt-XXHaZRr56a5N_kCndduK0"/>

Follow this link Send google static map via email same like your question here by another user.Hope this will help.

yes in using PHP and JavaScript you can pass static map URL and pass it through form submission and use in email
Get current location/ Coordinates through JavaScript
var latlon = position.coords.latitude + "," + position.coords.longitude;
var img_url = "https://maps.googleapis.com/maps/api/staticmap?center="+latlon+"&zoom=17&size=500x250&sensor=false&key=API_KEY&maptype=roadmap&markers=icon:http://maps.google.com/mapfiles/ms/icons/red-dot.png|"+latlon;
//here pass the value to input field
document.getElementById("map_image").value = img_url;
Inside form take input with id=map_image and type hidden than submit form and handle post request on next page
<input name="map_image" id="map_image" type="hidden" value=""/>
than for handling after submission of form
$map_image_url = $_POST['map_image'];
than you can use this as img in email template

Related

How to upload a "Image only from client side to SharePoint Custom List" using Rest Api ? not in Document Library and not in picture Library

I'm new to SharePoint & REST API. So kindly help me with Step by Step Instructions.
I have one custom list called "Attachment" within this custom list I have one Attachment column named as "Attach" which is created with the data type "Hyperlink or Picture".
Using Rest API I want to add the Image which is selected by the end user in client side (browser) to SharePoint Custom list named as "Attachment" under the column "Attach".
Help me with the working Code Samples.
Note: I'm trying this in visual studio 2017 as a SharePoint Hosted App.
This is my Default.aspx page code.
<div class="form-group">
<label>Attachments</label>
<input type="file" class="form-control" id="attch"/>
</div>
"I expect when the user selected any image using this control, I need to upload and store that image to custom List" not in document library , not in picture gallery. Only in Custom List.
Kindly Give me a Visual Studio Solution File (or) Give me a Clear Working code For Default.aspx and App.js with the Script.
Thanks in Advance!!!
The "Hyperlink or Picture" field only store the link of the image.
If you only want to store the image in custom list, we need store the images as attachments. I suggest you store the images into a document library or picture library, then use a "Hyperlink or Picture" to store the link of the images.
To upload image as attachment in list items using REST API, the following articles for your reference.
Working with files attached to list items by using REST
Uploading Attachments to SharePoint Lists Using REST
you need to create a document library instead and upload the image to it,
you can try this js to upload the image,
function _arrayBufferToBase64(buffer) {
var binary = ''
var bytes = new Uint8Array(buffer)
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i])
}
return binary;
}
function uploadfile(name, content) {
var createitem = new SP.RequestExecutor(appweburl);
createitem.executeAsync({
url: appweburl + "/_api/web/GetFolderByServerRelativeUrl('/sites/Tile of web/app title/Lists/list name/foldername')/Files/Add(url='" + name + "',overwrite=true)",
method: "POST",
binaryStringRequestBody: true,
body: content,
success: function (e) {
alert('done');
},
error: function () { alert("Error"); },
state: "Update"
});
}

Magento 2 : How to generate Add to Cart URL

I am looping some specific products on the home page but unable to generate the ADD TO CART URL in magento 2
How to generate ADD TO CART URL when displaying products in loop.
I know it's been a year since this has been touched on, but as I've just done what has been requested, I thought that I may post my solution to help others.
The other answers will work, but only for simple products, where no further input is required (e.g. selecting options). When using getAddToCartUrl(), Magento first checks if the products requires any options to be selected; if it does, then it will simply supply the URL to the product page instead.
To skip all of these checks and directly obtain the add to cart URL, then make use of the Magento\Checkout\Helper\Cart helper instead. If you are within a .phtml file, then this can be utilised simply by calling $this->helper:
$cartHelper = $this->helper('Magento\Checkout\Helper\Cart');
From there, you can generate the add to cart URL via getAddUrl(), ensuring you pass the product object as the parameter:
echo $cartHelper->getAddUrl($product)
For it to fully work, you must have a hidden field for the form key as described in the other answers, and if the product in question has compulsory options to choose from (e.g. a configurable product), then make sure you include those fields as well, otherwise you will get redirected to the product page itself, with a message informing the user that options are required.
The excellent solution is to use
$cartHelper = $this->helper('Magento\Checkout\Helper\Cart');
and after that
echo $cartHelper->getAddUrl($product);
this give add to cart URL every time
(for a simple product, for a simple product with custom options etc)
use following to generate add to cart URL in magento2:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$addToCartUrl = $listBlock->getAddToCartUrl($product);
Add your button code into form with form key.. It will work
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$addToCartUrl = $listBlock->getAddToCartUrl($product);
<form data-role="tocart-form" action="<?php echo $addToCartUrl; ?>" method="post">
<?php echo $block->getBlockHtml('formkey')?>
<button type="submit"
title="Add to Cart"
class="action tocart primary">
<span>Add to Cart</span>
</button>
</form>
You can generate "add to cart" url by following code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');
$addToCartUrl = $listBlock->getAddToCartUrl($_product);

Using Google Sites/Scripts: Send Input Values from a Form to a Support Email Address

Disclaimer- I AM A BEGINNER. If there is not a simple answer here, I will gladly review the correct tutorial, etc. But I've been looking for a couple days and I can't quite get this.
Use Case:
AS A: visitor viewing a Google Site
I WANT TO: fill out a form and select Submit
SO THAT: the information entered will populate an email and be sent to a specific address.
What I've done:
Created emailForm.html:
<html>
<body>
<script>google.script.run.processForm(document.getElementById('myForm'));
</script>
<div>
<form id='myForm'>
Subject:<input name='emailSubject' type='text'>
<br><br>
Body: <textarea name='emailBody' type='text'></textarea>
<br><br>
Add an Attachment: <input name='emailFile' type='file'>
<br>
<input type='button' value="Submit ZD Ticket" onclick='google.script.run.formSubmitReply()'>
</form>
</div>
</body>
</html>
Created sendEmail.gs: (NOTE: Script is incomplete. I have added my comments)
function doGet() { // This function creates the form on the google site for the customer to use
return HtmlService.createHtmlOutputFromFile('emailForm.html')
}
function formSubmitReply() { // This function is ran on the "Submit" button is selected and sends the email
var subject = // ?? HELP: In a perfect world, it would be as easy as HtmlOuput.getInput('emailSubject')
var body = // ?? HELP: In a perfect world, it would be as easy as HtmlOuput.getContent('emailBody')
var attachment = // ?? HELP: In a perfect world, it would be as easy as HtmlOuput.getContent('emailFile')
MailApp.sendEmail ('support#support.com', 'subject, body + attachment,
{name:'Support Request'});
}
​
My Assumptions:
I don't think I need to access any DB and I'm trying to avoid using a Google Spreadsheet. I just want to send the input values straight from the form to an email address.
I read one tutorial that suggested Logging the form values and then call that. But I don't know how to call the appropriate input from the form OR have those inputs added to the email. Sample function from Tutorial:
function processForm(theForm) {
Logger.log( // What goes here?
);
}
THANKS ALL for Any help!
You need to pass the form in to the call from your client code. You can retrieve the form using document.getElementById or simply make use of the fact that the parent of the button is the form, so you can reference it via this.parentNode. Try changing the html like this:
onclick='google.script.run.formSubmitReply( this.parentNode )'
Then in your server code you can use it all:
function formSubmitReply(theForm) {
var subject = theForm.emailSubject;
var body = theForm.emailBody;
var file = theForm.emailFile;
MailApp.sendEmail ('support#support.com', subject, body, {attachments: file});
}
When you have a form, the submission goes to a URL, so here is what you have to do
Modify the form code so that you
Write a doPost(e) method in your apps script code - this is where you will send out the email.
Publish your script as a web app and take the URL and replace the someURL in step 1 with the URL of the web app.

Orchard - add class or id to the body using fields

My questions is - how do I add a class or id to the body tag using a text field within Orchard?
So if I enter the word "product" in the text field then the result should be <body class="product">. I want to use this method instead of creating alternate layout templates as every page has the same layout but I need a different class for each page to reference a different colour scheme I have setup for each page in my CSS.
I have added a text field with the name Area to the Title ContentType in the backend. My problem is now how to get the value of the field to be put into the body in the Document.cshtml.
I have read Setting Unique Body Classes and IDs in Orchard and Using Alternatives for Document.cshtml in Orchard CMS but I still can't get it to work! The second one seems like what I want to do but so far I have been unable to acheive it.
Any answer would be very appreciated?
Thanks
Andy
I am so frustrated that there is no readily available solution found in the net about this. Since I am more comfortable coding in jquery & js...
Here's my solution: Assuming you have jquery loaded...
#using(Script.Foot()) {
<script type ="text/javascript">
//<![CDATA[
$(document).ready(function () {
var url = window.location.pathname;
var count = url.match(new RegExp("/", 'g'));
var urlsplit = url.split("/");
var page_class = urlsplit[count.length];
alert(page_class);
$('body').addClass(page_class);
});
//]]>
</script>
}
The easiest way to achieve this is to use the Classy feature from Vandelay.Industries.

How can I submit a DOM table to php?

I have a <table> in a web page that I populate using JavaScript code like this:
var cellBarcode = row.insertCell(1);
var textNode = document.createTextNode(barcode);
cellBarcode.appendChild(textNode);
var cellItemName = row.insertCell(2);
var textNode = document.createTextNode(itemName);
cellItemName.appendChild(textNode);
I need to save its data to my database... So I need to know how I can submit it to php... Is it possible...? If yes, please provide some sample codes that are easy to understand for a beginner like me... thanks...
Yes, you can submit this information to a server-side script, but not without extra JavaScript code.
The extra JavaScript code would collect the information in the table (either from the DOM you've built, or by accessing the same data you used when building the table) into a string, which can then be sent to the server using one of standard ways.
Since you've used the term "submit", I'm assuming you want to send the table's data as part of an HTML <form> submission, you can put the generated string in an <input type="hidden"> element.