Using TAL language to find info by user in Plone - plone

I've installed collective.portlet.tal.
My goal is to show for each user, his info in his own folder by this portlet.
Fox example now I want to show: username and email.
By default I have this portlet that show nothing of special:
<dl class="portlet portlet${portlet_type_name}"
tal:define="portal_state context/##plone_portal_state;
context_state context/##plone_context_state;">
<dt class="portletHeader">
<span class="portletTopLeft"></span>
<span>
Header
</span>
<span class="portletTopRight"></span>
</dt>
<dd class="portletItem odd">
Body text
</dd>
<dd class="portletFooter">
<span class="portletBotomLeft"></span>
<span>
Footer
</span>
<span class="portletBottomRight"></span>
</dd>
I've inserted in the Body this line to get the username of the folder, but it returns the name of the visitor. If I'm the admin, it will show "admin", or if I'm a member, it will show the member's name...and so on.
<p tal:content="user/getUserName"></p>
How can I show the creator of that folder?
How can is possible get the emailof that user for that folder?

You are looking for the Creator of your folder:
<p tal:define="creator context/Creator;
mtool context/##plone_tools/membership;
author python:mtool.getMemberInfo(creator)"
tal:content="python:author and author['fullname'] or creator">Author name</p>
The above snippet looks up the creator userid (this defaults to the owner of the content object), and uses the membership tool to look up a member info object for that user. We then display the user's full name, or if the creator is not a Plone user, just the userid.

Related

Automated reply issue on Contact Form 7

I have a job portal and incorporated 'Contact Form 7' to apply for the job. On the "To" field, I have employer email address "employer#gmail/yahoo/whatever.com" and "From" field "[your-name] <no-reply#mydomain.com>". When an employer receives the email from the candidate and responds to it by reply, it sends an email directly to candidate's inbox (which is working absolutely fine). But the problem is when the employer has set up an automated-reply email, it sends to my email address "no-reply#mydomain.com" and candidate doesn't receive anything from the employer. Not sure, why automated-reply ignore the candidate email. Please help me on this.
I am using following plugins:
"WP Job Manager" for job listings
"Contact Listing for WP Job Manager" for apply job form.
Below is the Contact Form7 setup sreenshot
And this is what employer receive
And here is the code of the HTML:
<div class="form-group">
<label>Your Name *</label>
[text* your-name class:form-control]
</div>
<div class="form-group">
<label>Your Email *</label>
[email* your-email class:form-control]
</div>
<div class="form-group">
<label>Application Subject *</label>
[text* your-subject class:form-control placeholder "Ex: Applying For Accountant"]
</div>
<div class="form-group">
<label>Application Cover Letter</label>
[textarea your-message class:form-control maxlength:500]
</div>
<div class="form-group">
<label> Upload Resume</label> <em style="font-size: 12px;">( pdf, doc, docx )</em>
[file upload-file limit:2mb filetypes:pdf|doc|docx class:form-control]
</div>
<div class="form-group">
[submit "Send"]
</div>
You have to use Mail(2) section for auto responder to work. Here is the official documentation Autoresponder setup for contact form 7
Although you can follow below step:
Scroll down on your contact page and you will see Mail(2) section.
Select Use Mail checkbox and then copy email shortcode [your-email] and paste it into To textbox. We need this shortcode to send autoresponders.
This [your-email] shortcode will catch users email which he will enter in email box while submitting a contact form.
Then enter your message which you want to send via autoresponder and then click on save button. Now your autoresponder is setup.
Below image for your reference

Remove field from user profile in alfresco community

I am using alfresco community 5.0.d
I want to remove google username field from the user profile.
So far,
I found the file that handles this form, userprofile.get.html.ftl and userprofile.get.js. Now as I comment out the div tag for google username field in userprofile.get.html.ftl then the whole form is getting hidden without any error on console.
Form is coming blank as shown in screenshot below.
Any idea how to remove?
Thanks.
I added hidden class to the div to hide them instead of removing it,as it is not displaying any of the form fields as you mentioned.
<#if profile.googleUsername?? && profile.googleUsername?length!=0>
<div class="row hidden">
<span class="fieldlabelright">${msg("label.googleusername")}:</span>
<span class="fieldvalue">${profile.googleUsername?html}</span>
</div>
</#if>
And for the Edit fields,
<div class="row hidden">
<span class="label"><label for="${el}-input-googleusername">${msg("label.googleusername")}:</label></span>
<span><input type="text" maxlength="256" size="30" id="${el}-input-googleusername" value="" <#immutablefield field="googleusername" /> /></span>
</div>
And it is working fine.
I found the reason for form not being displayed was that I was just removing the div tags but not the dom.get method for those fields.
Files to be modified:
profile.js
userprofile.get.html.ftl
Solution:
Remove the dom.get for the fields that you want to remove from
profile.js.
Remove the div tags of those fields from the
userprofile.get.html.ftl.
Restart the tomcat
Voilaaaa !!!
Fixed and Done.

Check user email status before page loads

I'm using an unless spacebar function to check if a user has verified their email address. In production, I assume due to a delay, the screen displays this notice and then changes after a second if the email has been verified. Is there a way to slow down the page load so the users email status is checked before the page loads?
<template name="mainLayout">
{{#unless currentUser.emails.[0].verified}}
<p class="alert alert-warning text-center">We have sent you an email to verify your email address. All users must confirm their email address to access the BHR platform.</p>
{{else}}
<div id="content" class="content">
<div class="container">
{{>Template.dynamic template=main}}
</div>
</div>
{{/unless}}
</div>
</template>
The delay come because the first time the template is rendered the Meteor.user() object has not yet been fully loaded. Then it loads and reactively the sections get swapped.
You need to show a loading screen/spinner while the user object is loading. How you do this will depend on what router you are using.
I believe this is what Michael was suggesting. Wrap you templates in:
{{#if Template.subscriptionsReady}}
{{/if}}

Problems getting Iron Router to work on my project

I'm trying to create a quiz app on Meteor and have had trouble setting up Iron Router forever. I'll try to give a visual:
This is the front page:
Image 1
When a user clicks on the button shown above, I want the first question to show up, whose contents are filled from MongoDB.
Image 2
This is what my router looks like ("question" is the name of the question template, as seen in image 2):
Router.route("/quiz/:_id", {
name: "question",
data: function(){
return Quiz.findOne(this.params._id);}
});
Now, in order for me to get from image 1 to image 2, I have to use a mongo object _id in the html file.
<template name="main">
<div class="jumbotron">
<h2>
Welcome to Simple Meteor Quiz app!
</h2>
<p>
To try it out, simply click "start" below!
</p>
<p>
<a class="btn btn-primary btn-large" href="/quiz/cieLkdzvGZPwrnZYE">Start</a>
</p>
</div>
</template>
When I click "Next Question" on image 2 to go onto the 2nd question, it doesn't work. I don't know how to make this process dynamic.
The way it looks to me right now is that I physically have to create a new route for every single question, which would look really ugly really quickly.
Any way to help implement Iron Router in this scenario? I read Discover Meteor and thought I fully understood how Iron Router works, but the more I try to fix this, the more I get confused.
Edit:
To solve my dilemma, I simple created a helper function which I could place behind the /quiz/ in the main template to lead me to the quiz question, based on a suggestion by Michel Floyd.
So the helper ends up looking like this:
Template.main.helpers({
nextQuestion: function(){
queue = Quiz.find().fetch();
return queue[0]._id;
}
});
Then attached to the URL like this:
<a class="btn btn-primary btn-large" href="/quiz/{{nextQuestion}}">Start</a>
Basically just spit out the first _id of first item in the array by making the collection an array via find().fetch(). Will probably randomize the _id at a later time.
You need a way for each template to know what the next question is. For example you can add a nextQuestionId key to your Quiz object. Then your template can be:
<template name="main">
<div class="jumbotron">
<h2>
Welcome to Simple Meteor Quiz app!
</h2>
<p>
To try it out, simply click "start" below!
</p>
<p>
<a class="btn btn-primary btn-large" href="/quiz/{{nextQuestionId}}">
Start
</a>
</p>
</div>
</template>

MVC Field Validator for an Email Address is generating an extra span tag

I have a MVC3 application that was has an extremely poor master CSS file that I can't edit without a significant amount of redevelopment work (which is coming... but I can't do this right now). I have the following code block:
#Html.ValidationMessageFor(m => m.Email)
#Html.ValidationMessageFor(m => m.Password)
#Html.ValidationMessage("")
There's a fair amount of structure around these three lines.
The problem that I have is that this generates the following HTML when it renders the first two error messages:
<div class="field-validation-adddiscount">
<span class="field-validation-error" data-valmsg-replace="true" data-valmsg-for="Email">
<span class="" for="Email" generated="true">
The Email Address field is not a valid e-mail address.
</span>
</span>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Password"></span>
<span class="field-validation-error" data-valmsg-replace="true" data-valmsg-for="">
The email address or password provided is incorrect. Please try again.
</span>
Why is this generating two span classes for the Email address validation message (and can I get rid of it or inject a class into the span? I've attempted to set the #id in the ValidationMessage, but it assigns this to the parent span and the sub-span still causes the css to go mental (I have to work with a really poor css master file - one thing that's on the "i wish the client would pay for the time to rewrite it" list)
I know it's related to jquery unobtrusive validation as I've attempted to implement the fix from this post: Difference between html rendered when client validation is true in MVC3 however this just seems to do weird things with the validation including preventing the email validation message from appearing at all.

Resources