When the user submits a custom CCK form and a field marked as REQUIRED is empty, I get an xyz field is required..
How can I customize this message without modifying core modules?
Depending on the error message and how you need to change it, you may be able to use the String Overrides module to replace the string used to generate the message.
Another option is to create a custom module that overrides the validation function for a particular form or field, replacing any error messages with the messages of your choosing.
Related
I'm using python-telegram-bot wrapper to create NLP based chatbot and I want users to have an option how to use the bot:
InlineKeyboardButton menus
natural language conversation
For the first option I am having several ConversationHandlers defined, most of them are having entry_points defined as single CallbackQueryHandler:
location_handler = ConversationHandler(
entry_points=[
CallbackQueryHandler(
callback=nearest,
pattern=NEAREST_CB
)]
And for the second option I am using MessageHandler:
text_message_handler = MessageHandler(Filters.text & (~Filters.command), call_model)
I wanna enter one of those ConversationHandlers whenever my model (call_model function) returns an appropriate tag, but have no idea on how to do it.
text_message_handler = MessageHandler(Filters.text & (~Filters.command), call_model)
I wanna enter one of those ConversationHandlers whenever my model (call_model function) returns an appropriate tag, but have no idea on how to do it.
call_model is your handler callback, though, right? The callback can't determine whether or not the handler is executed.
That is the job of the handler. So you should probably implement either a custom filter to use with MessageHandler or just a custom handler and put your NLP logic in there. Please see this page for details on custom filters and this page for the abstract Handler class that you'd need to implement for a custom handler.
Disclaimer: I'm currently the maintainer of python-telegram-bot
I'm using Alfresco 5.2 Community. I'm trying to edit the template wf-email.html.ftl file found in Repository> Data Dictionary> Email Templates> Workflow Notification> wf-email.html.ftl.
In the line
<p>Hi,</p>
I want to add the recipient's name in the message, something like
<p>Hi John,</p>
Is this possible? If yes, how is it achieved?
Unfortunately, the assignee is not passed as an argument to the template, so it is not available to the template. You can see this by looking at the source of the class that actually sends the notification:
https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/workflow/WorkflowNotificationUtils.java
Looking at that class you can see where things like the workflow ID, title, and description are added as arguments that get passed to the template renderer:
templateArgs.put(ARG_WF_ID, taskId);
templateArgs.put(ARG_WF_TITLE, taskTitle);
templateArgs.put(ARG_WF_DESCRIPTION, description);
But the assignee is not passed.
You could lookup the workflow and then get the current task and then get the assignee to that task, but that's probably not the best way to go about it.
If you really need this, I would extend the existing WorkflowNotificationUtils.java with my own, and add in the assignee as an argument to the template. Or I'd turn off the default notifications and just use my own notification classes that my custom workflows call.
I have a Drupal website that uses the Quiz module to administer tests to visitors. These tests need to be available to anonymous users. My problem is that I need to be able to ask the test taker to enter name and e-mail so the results can be sent to them. I just don't know how to go about doing this. I consider myself a beginner in Drupal and PHP.
Any help would be appreciated.
-First of all, create a custom module.
-Secondly, you need to add the email address and name fields. You can do this by either adding the two fields via hook_form_alter in your custom module or by enabling and using the Short Answer module/field that's included in your Quiz module and then customising the style of the field according to your needs (because it'll look like a question). Personally, I would recommend adding them using hook_form_alter. Plus, I suggest you learn about Hooks in Drupal, it will make your life easier.
-You have to validate and retrieve the values for the two fields. You can also use the same form_alter hook for this. Add a validation and a submission function to the validate and the submit stack of your Quiz form ($form['#validate'][] = 'your_validate_function'; and $form['#submit'][] = 'your_submit_function';). You can validate your email by using Drupal's function valid_email_address and, of course, you can validate other fields and calling Drupal's form_set_error to notify users of any input mistakes.
-To send your email after the Quiz is submitted, call Drupal's drupal_mail, in your submit function, which basically takes all the parameters needed to send an email. You'll have to create a hook_mail in your custom module. Check out an example of how to do this here. You can retrieve your form values (name and email address) from the local array $form_state['values'], pass them as $params to your drupal_mail function and add them to the body of your email in your hook_mail function. And that's it :D
-Alternatively, you can send an email by creating an action and assigning an action to be performed after a user has completed this Quiz. The Quiz module has support for that. Here's an example of how to write an action.
You may also use hook_quiz_finished instead of form submit callback.
Quiz module uses it to perform actions like sending results over email at the end of a quiz.
function mymodule_quiz_finished($quiz, $score, $session_data) {
//Sending e-mail.
}
If you ended here and you are using Drupal 7, go to Rules http://www.yourwebsite.com/admin/config/workflow/rules, and set the rule that the Quiz module has made available already to active under the settings, the rule is called "Send quiz results at the end of a quiz". I couldn't find the ability to do this anywhere within the Quiz config itself. Tested and its working. Be sure that the Rules Module UI is enabled to allow you to make the edits.
I'm having some problems setting up a tokenized email to use the tokens I've created in my module. I am using this in a tokenized email [example-contact]. I've implemented the example_token_values() and example_token_list() in my module and I've also created a trigger in my module. My module has a form, created with the form API, that gets stored in a custom table. My tokens are listed when I view all available token so I know that example_token_list() is working but when example_token_values() is called $type doesn't come up as equal to 'example'.
I need to pull information from the submitted form and display them on the tokenized email that is sent out. Am I missing a function? The Trigger I created is working and fires when the form is submitted and the Action is sending out the email the problem is that the tokens are not being replace with the form's values.
Is there a function that I need to implement that will call example_token_values("example",$form)?
An implementation of hook_token_values() can use any values for $object; if the module needs to use the value of $form passed to one of its functions, it can use it.
I want to use a view to select nodes in a content type field. This view must receive an argument that is another field of the content type.
Can someone explain me how to pass the argument from the field to the view?
Excuse my poor english
You might be able to use the Views Arguments Extras module. It will allow the argument of the view to come from a cck field. Some more details about this module (from its project page):
This module contains a group of view handlers and plugins that add the following options:
Argument Default Current Node CCK
allows for cck field values of the current node to be loaded as default arguments
Argument Default Request Params
allows for get and post params as default values
Argument Order Sort
a sort handler, that allows for the order of items to be based on their order in a multi-value argument
I believe you can use the argument validation to validate the argument, and at that point you are free to change the $handler->argument value before it is passed in to Views.
If you just want to change what the view displays based on the value of a CCK field, the easiest way I have found is to embed a view into the template using views_embed_view(). Something like this in your template file would work I think:
//Use the dsm function to print out your $node object
//to get the name of the field you want to pass as an arg
//like this: dsm($node);
//Assuming that the value of that field is in $node->cck_field['0']:
print views_embed_view('name_of_view', 'name_of_display', $node->cck_field['0'];
views_embed_view() only needs the first argument, the name of the view, to work. It will return the HTML for the default display of the named view. We pass it a specific display as a second argument. Anything after the second argument gets passed into the view as an argument, so we pass in the value of the field as an argument to the view. See this link for some documentation on how the function works.