year not loading in email - email

I'm running Moodle 2.9.1 and I'm sending an email to the new users of the platform. However, when I try to show the year it doesn't work. My current code reads something like this...
$string['newusernewpasswordtext'] = '
(...)
<p >
© {$a->year} xxxx
</p>
';
and the email would display
© {$a->year} XXXX
I would like to dump the variable in the mail so i can figure out what's being processed but i have tried several different smarty ways to no avail. Any suggestions?
thanks!!

Might be because of the <p> tags. Just use blank lines instead of <p>
Also check if the value is being passed - have a look at function setnew_password_and_mail() in /lib/moodlelib.php
and add this
$a->year = 'xxxx';

Related

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.

VBA getElementById with dynamic ID

I've been searching this whole forum, msdn and specialised tutorials and I can't find the answer for VBA:
How can I make the getElementById work in an access VBA module where the id to find is dynamic?
Let's see the html code:
<DIV id=rowToolTipContainer>
<DIV class=contactsCard id=resultsTooltip1122286Contents style="DISPLAY: none">
<TABLE class="shadow-box tooltip">
<TBODY>
And how I'm trying to find it:
Dim ResultDIV As HTMLDivElement
Set ResultDIV = HTMLDoc.getElementById("resultsTooltip*")
Let me say the html returned has a different id (the numbers change) depending on each result so the id for each DIV is always:
id=resultsTooltipxxxxxxxContents where xxxxxxx are always different numbers
Any help would be highly appreciated.
Try something like this one:
Dim ContainerDiv As HTMLDivElement, ResultDIV As HTMLDivElement
Set ContainerDiv = HTMLDoc.getElementById("rowToolTipContainer")
For Each ResultDIV In ContainerDiv.GetElementsByTagName("div")
If ResultDIV.ID Like "resultsTooltip*Contents" Then
'' What do you want to do here?
Exit For
End If
Next
Identify the closest parent tag that always contains the ID (manually, by looking at your HTML).
Enumerate all descendant <div>s of that tag, testing their ID property with Like.

How to loop through a variables in Magento Email Template?

Let's say I've the following variables to pass to my Email Template:
$vars = array(
'products' => $products,
);
Where $products is a collection, how could I iterate over this collection in Email template?
I don't believe that Magento's templating engine is clever enough to do loops. Instead, use an inline block, as Magento does for order items. Something like this:
{{block type='core/template' area='frontend' template='path/to/your/template.phtml' products=$products}}
Hope that helps!
Thanks,
Joe
The above works, but an alternative would be to let your XML do the work by calling the layout handle in the email template:
{{layout handle="email_stuff"}}
In your local.xml or module.xml or where ever you like:
<email_stuff>
<block type="yourblock/type" name="email_stuff" template="path/to/template.phtml" />
</email_stuff>
I guess the main difference is where you're doing most of your email "work". I've used this method for loading in email headers/footers that stay the same in each template. The previous answer is likely simpler for basic tasks, however.

Find and replace variable div contents

I have a php page which contains a large amount of HTML in it. One part of the HTML has a div in the following format:
<div class="reusable-block" id="xyzabcwy">there is a lot of HTML here which may be in any format</div>
Keep in mind, this div is contained within the DOM at any location however, I do know the div ID programatically.
I was originally finding this string within my database, since a record of it exists there however, the format between the data in the database record and the page are sometimes different due to whitespace but other than the white space, the strings are exactly the same. The problem is, I don't know what format the whitespace is in.
It seems it is better to write a regular expression to find this div and replace it entirely.
I could use a hand though.
Other ideas are also welcome.
Many thanks!
If you are using jQuery,
$('#xyzabcwy').html(new_data);
if not
document.getElementById('xyzabcwy').innerHTML = new_data;
otherwise, here is a PHP example.
Edit: PHP
<?php
$id = "xyzabcwy";
$html = "<div id=\"" . $id . "\">this is html</div>";
$newdata = "test";
echo preg_replace("#<div[^>]*id=\"{$id}\".*?</div>#si",$newdata,$html);
?>
 This should output
<div id="123">test</div>
Answer from: Replace a div content with PHP

Simple paragraph break

I am trying to make a simple paragraph break in my text file (name.js) so that when the iphone pulls the information (name.js) there is not one big run on paragraph. I have looked and looked and cannot find this information can you help me project is due at this time...
try something like this in the javascript:
var pageBreak = document.createElement("/p");
document.getElementsByTagName("tagToInsertBreakAfter")[0].appendChild(pageBreak);
I am away from my machine so i cannot check but try a \n or \r\n
Well it had to be one or the other it'
<br />
i just hacked a widget and tried it. By the way i am assuming you are doing some like the following
// localised strings
var backString_01 = "World Second <br />offers unbeatable exchange rates and exceptional service for foreign exchange and international payments";
then outputting to the document with
document.getElementById('services_headline').innerHTML = backString_01;
With the element in the html something like ....
<div id="services_headline" apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis"></div>