I'm new to Drupal 6.10 CMS and PHP too. I'm creating my website with drupal and I have found a module called Webform I like it, it's pretty easy to create forms with different types of fields and file uploading. The one thing that i can't figure out is how to add Rich Text before all fields. Something like introduction to the form. This module has "Description" field that will show text as a plain text but it doesn't have rich text in it.
What can I use to make that happen. Is it possible to hardcode html there or is there any other modules that can allow to do something like that?
Thanks
the value of the "Description" field is passed through _webform_filter_descriptions(). this function has a $strict parameter, defaulting to TRUE, which determines if the description is filtered through filter_xss() or not. filter_xss() allows some html:
'a', 'em', 'strong', 'cite', 'code',
'ul', 'ol', 'li', 'dl', 'dt', 'dd'
so you can either restrict your "rich text" html to these elements, or modify _webform_filter_descriptions(), setting $strict to FALSE. if you do latter, be aware of the security implications (users with rights to create webform descriptions could enter malicious html - that's what filter_xss() protects against).
I think all you need to do is set the 'input format' to 'full html' and then you can use whatever HTML/CSS tags you want to style the text.
You can achieve this by the creating a Form Component "MARKUP" from the drop down option when creating new fields.
From this part, you are able place html and php in this box as you desire.
You also have the ability to choose input format to have more control over how you want to work with this element.
As the OP says, the "Confirmation" box shows up with the WYSIWYG editor toolbars, but the "Description" box does not.
The simplest way to deal with this is simply to handcode the HTML you want in the Description box. While nowhere does it say you can do this, you can, and it works.
Here is a short howto I wrote on getting custom code to run with Webform.
It details writing a custom module, copying the Webform template to match the nodeID, and adding custom javascript/jquery for form processing.
http://docs.quantact.com/drupal-webform-custom-php-code
Related
I've been trying for a while now to find a decent way to insert and modify text in a tinyMCE textarea using jQuery with little success. Most of the answers that people provide are generally only being used for a single tinyMCE textarea, or by calling a tinyMCE field based off of an ID. This is all well and good but my project has me creating repeated fields dynamically on the page, which makes it difficult to get a specific tinyMCE element.
Before I implemented tinyMCE I was calling the repeated fields by their class in association with a parent div.
Ex:
$(this).parents(".main-category").find(".js-description").val(product_data['description_' + $('#language').val()]);
The above code is run when I change the product via dropbox. "$(this)" being the dropbox, it then calls for the parent div and finds the description textarea where it would then input the correct default data (passed through from a controller) into the field.
the problem here is that when you initialize tinyMCE, the original text area is all but buried and become inaccessible with this method.
the tinyMCE site provides documentation for how to insert text into a tinyMCE field, but these only work when there's a single tinyMCE element on the page or when you are manually inserting the fields yourself.
// Sets the HTML contents of the activeEditor editor
tinyMCE.activeEditor.setContent('<span>some</span> html');
// Sets the raw contents of the activeEditor editor
tinyMCE.activeEditor.setContent('<span>some</span> html', {format : 'raw'});
// Sets the content of a specific editor (my_editor in this example)
tinyMCE.get('my_editor').setContent(data);
// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added
tinyMCE.activeEditor.setContent('[b]some[/b] html', {format : 'bbcode'});
Is there any way to convert any of these into something that I could use? Or is there some other method that I can use to insert information into the text areas?
Thanks in advance!
Yes, the tinymce source element becomes inaccessible when the editor gets initialized. This is necessary because tinymce creates a new contenteditable iframe which is then used to edit text. The editor text gets writen back to the former textarea on several events.
You asked for a jQuery way to acces the tinymce editor content. This is possible.
The following example shows howto acces the editor body element, looks for a html element with class .js-description and resets its value.
var editor = tinymce.activeEditor || tinymce.get('my_editor_id') || tinymce.editors[0];
$(editor.getBody()).find(".js-description").val('new_val');
Hi I am looping through a channel in EE2 and I am outputting all of the fields values but how do I output the fields title that I labeled it in the backend?
CODE:
<!-- Loop to out put a field called Location -->
{exp:channel:entries channel="vacancies" disable="pagination|member_data|categories"}
<p>{vacancy_location}{title}{/vacancy_location}: {vacancy_location}</p>
{/exp:channel:entries}
DESIRED OUTPUT:
<p>Location: Some Location</p>
What worked for me was installing SafeCracker module that is shipped with EE2 and using its {label:} tag
http://expressionengine.com/user_guide/modules/safecracker/index.html#label-my-field-name
You might be able to accomplish this via the SQL query tag, but generally speaking the labels assigned to fields in the back-end are intended to be for use only within the Entry Publishing/Editing screen. The labels for these fields that are seen by the people entering content into the system may not always necessarily be the same labels you want to expose to visitors to your site on the front end.
Like #stoep mentioned, you may have better luck writing a custom plugin to handle this, if writing SQL query tags in your template won't end up as a viable option.
You can't.. The only way to get it is by extracting it from the database. You could write a custom plugin for the task. Another option is to put the field label in the Global Template Variables.
Edit: I quickly created the plugin for you -- you can grab it at https://github.com/Stoep/pi.field_information , place it in third_party/field_information/
Usage:
{exp:field_information channel="news" field_name="news_content" information="field_label"}
{exp:field_information channel="news" field_name="news_content" information="field_instructions"}
I wonder is someone can help, I'm building a website, which is driven from a database. It will consist of user submitted information.
Currently all the information is pulled from a record in the database and is being output via a PHP echo, what i would like too do is add a feature that would allow me to edit the information if incorrect from the websites front end.
I have seen many websites have some form of edit icon next to information in there databases, when clicking this icon the echoed text changes from text to a text field and you are able to update the field being echoed from the database.
Im a designer so have limited knowledge of how functionality for this kinda feature might work.
please could anyone let me know how something like this might be achieved.
many thanks.
You would need to build some kind of javascript functionality to allow the in-place editing of those data bits. One possible solution is a jQuery plugin like jEditable.
Then you need to build a server-side script in something like PHP or ruby where it would take the submitted information and update the database.
well the process is the same for the front-end and back-end. it depends whether you want you build a password protected editable forms or just editable for everyone.
One way you can do this is
echo your information into text inputs
give them a css class that removes the border and makes it transparent
make it readonly(so someone couldnt tab into it and change it)
add a javascript onclick event that changes the class to a normal
text box that is not readonly
add a javascript onchange event that uses ajax to save the new
information into the database when they are done typing, or press enter
after the ajax is done turn the text box back to the first css class
EDIT also add a onblur event that changes it back as well
you could even change the cursor for the text input to a pointer instead of the default (text) cursor so that is looks like you can click on it.
.
now html5 has contenteditable attribute which you can set for elements
simple example:
www.hongkiat.com/blog/html5-editable-content/
simpler demo:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_global_contenteditable
I know this is not a drupal forum but, as I’m not getting any response there, I decided to give it a shot here.
I’m creating a web site that accepts custom content from users. So, for that matter, this site has a form and a custom module. Instead of using admin theme, this form is placed inside custom template which is created to have a uniform look with the rest of the pages. As a result, creating form elements through hook_form is out of question. Here’s where my problems lie. As this form uses custom theme, I’m not sure as to what can I do to make drupal know that user is submitting new content data when the form is submitted?
Would I need to use same query string that of content submission page of admin page like - ?q=node/add/page for action attribute of the html form?
(OR)
the only way is to map the url to my custom function and invoke some sort of hook inside of it?
Thanks
You can literally create any markup you want for your form, all you need to do is use the #theme attribute when you define the form. With it you can set theme functions for the form itself and any of the elements.
It is a very bad idea, not to use Drupal's FAPI. It solves so many problems for you, and not using it would be the first step to take if you want to open up a security hole in your site. A development framework like Drupal is not of much worth, if you don't use it's APIs.
Edit:
First thing to do, is to go to Drupal's FAPI reference. You can learn almost everything about the FAPI there.
You could use a template if you want, is just basic Drupal theming, but I would advise against it. It would be a lot more maintainable if you created theming functions for all the elements and used that instead, you could just loop through all the elements and render them like Drupal does, instead of having to edit a template file each you need to change the form. It might be a but more work now, but there's a reward to that work: cleaner and more maintainable code.
In code it looks something like this:
$form['item'] = array(
...
'#theme' => 'theme_function',
);
Doing this, the element will be rendered using the "theme_function". You can see an example of such a theme function for textfields.
I have a few Views on my Drupal 6 site which take care of some of a node's fields.
For example, I have a content type called Country, which has a field called Capital. I've excluded this field in the node display, but there is a view that takes the node ID as an argument and displays it in the right column. This is all very pretty and has been working out well for me, but how do I take care of the node preview mode? Since the node isn't saved yet, the Capital field won't have its new value yet.
Note: I am ready to do some very dirty hacks to make this work :)
don't hack drupal! :)
One of not so simple and unchecked idea:
use hook_form_alter or hook_nodeapi with validate in custom module, there's you should see data of new capital field, save it somewhere (for example, into sessions), and show it's into block via theming Views field.