hey, im trying to do a multi file upload on my form, i used form api for that and drupal_render , but i cant find where i can do $form['uploadfield']=array(...multi files amount=3)
anyone has code to implment multi file upload in form api on d6?
Currently I do not think this is possible through the FAPI. See the discussions below:
http://drupal.org/node/452446
http://drupal.org/node/625958
There are some other options however. You can try using a Drupal module that implements this such as SWFUpload or Image FUpload (if you want to upload images).
SWFUpload can be used with CCK's Filefield and Image FUpload can be used with CCK's imagefield
EDIT: If your form is used for a custom content type, these articles/discussions should be helpful to you:
http://drupal.org/node/722268
http://drupal.org/node/702156
http://www.openbandlabs.com/blog/2009/06/programmatic-cck-content-type-creation
Using these methods, people have been able to add a CCK FileField to their custom content type.
Related
I have add some dashboard pages to my conrete5 install. One of pages has a form that needs allows the user to upload an image. Are there any libraries for uploaded images of shall I do it in native PHP? I found this in the documentation but I don't think its what I want.
I thought I'd ask before I started and to see if anyone else has done anything like this before
I would recommend making use of the built-in Asset Library helper. This will add a field to your form that allows the user to access all of the images in your site's File Manager, and upload a new image if necessary. Here's the relevant page in the concrete5 documentation.
Let's say you wanted to add a field to your form called "photo". Here's an example of what you would add to the part of your dashboard page's view where the form is rendered:
$al = Loader::helper(‘concrete/asset_library’);
$al->image('photo', 'photo', 'Select a photo', $photo);
In this case, $photo is used to represent the currently-selected image, if known.
First of all, I am absolutely new to WP.
I am hoping to build a site using WP and figured out how to manage every thing except one feature. The feature that is required is to be able to submit a form with files (images in particular) by a non member.
For example, you should be able to visit the site and fill a form and submit your image along it.
Is it possible to upload files as above? How is this achievable?
Thanks in advance.
If you are not a wordpress coder , I would sugest you use a plugin for that .
Some options :
http://wordpress.org/extend/plugins/user-submitted-posts/
http://wordpress.org/extend/plugins/tdo-mini-forms/
http://wordpress.org/extend/plugins/quick-post-widget/
http://www.gravityforms.com/category/features/
and many more ..
read also this tutorial : http://wp.tutsplus.com/tutorials/allow-users-to-submit-images-your-site/ - it is not for VISITORS but for registered users - but it might help you to understand what is needed to be done .
I would use the Contact Form 7 plugin to do this, as it's extremely easy.
In the plugin settings you'll be able to choose what parts of the form you'd like to include, adding a way to upload is one of those options. You can even limit the type of file that is being used as well the max file size.
Once you create a form in the settings, you just use its shortcode to add it to your Wordpress page.
Yes you can upload file, but it is not a Wordpress specific solution, unless you want to use a plugin. You can code html/php as per usual to achieve it:
http://www.w3schools.com/php/php_file_upload.asp
To embed it on a page, you can create a Page in Wordpress, and assign it a custom page template that you create with the upload form:
http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
I am building a WordPress website that will allow members to upload media such as videos, images, etc. They will do this on a public form at for example: domain.com/upload
The form will ask for a Title, a brief summary, show some categories to choose from, and finally a file uploader. The user will then be able to submit the form and it will appear on the site as a post but instead of being just text it is a piece of media.
I have created a custom post type and all seems to be fine, the problem I have is how to deal with the media upload, as the default WP method is to upload an item and then manually insert it into the post (and you can have as many inserted as you like). Where as I want users to be only able to upload one file per post and not have to insert the file into a post because the file itself is the post. They will also be able to upload a featured image.
Any ideas on how I can develop this? Thanks.
You could use WP upload methods to upload your file to the server. Then (depending on your upload's media type) you would insert HTML representation of the file into the post (e.g. parse a text file, create tag for image or embed a video).
If you want to see some working example, please let me know. I just outline the flow:
wp-handle_upload() to physically upload a file
wp_update_post() or wp_insert_post() depending on whether you're creating a new user post or editing existing one. Both methods require one argument - Post object. That's where you put your content (as a post_content field of course) and post data
I'm trying to simply display an RSS feed as part of my site. A user will put in an RSS URL into a CCK field and I want to take that URL and display the latest RSS results.
I assume there's a module for this but I can't seem to find it.
http://drupal.org/project/feeds will do this and a lot more.
Here's a good video to get started
http://developmentseed.org/blog/2009/dec/15/importing-and-aggregating-stuff-feeds
Regarding your request about integrating with CCK, I don't know how you can do that but that may not be necessary because the feed URL is entered through a dialog of its own. And you can always add other CCK fields to the Feeds Content type.
I ended up using the simplepie module and used the function simplepie_get() included within.
The main feed aggregators are the the core aggregator module, feedAPI module, and the newer feeds module. I'm not sure any of them are set up to integrate with CCK in quite the way you're describing. I suspect that will require some custom development.
If you don't need the feed data in the Drupal database, you could use a javascript library to bring in the feeds on the client side.
Node reference fields in Drupal are displayed as lists by default. Is there a way to change that?
I'd like to output them as JSON so I can create a fancy JavaScript visualization.
You can modify it in 2 ways: via custom module with function hook_form_alter or via theming (preprocessing form or templating form).
http://api.drupal.org/api/function/hook_form_alter/6
http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
For AHAH: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah
Also, nodereference already have little ahah: "autocomplete" in field editing of custom node type.
Consider the Content Templates (Contemplate) module. Here is a quote about it (from the module's project page):
... allows modification of Drupal's teaser and body fields using administrator defined templates. These templates use PHP code and all of the node object variables are available for use in the template. An example node object is displayed and it is as simple as clicking on its properties to add them to the current template.
This module was written to solve a need with the Content Construction Kit (CCK), where it had a tendency toward outputting content in a not-very-pretty way. And as such, it dovetails nicely with CCK, adding a "template" tab to CCK content-type editing pages and pre-populating the templates with CCK's default layout. This makes it easy to rearrange fields, output different fields for teaser and body, remove the field title headers, output fields wrapped for use with tabs.module (part of JSTools), or anything you need.
But Content Template can actually be used on any node type and allows modification of the teaser and body properties before they go out in an RSS feed, search index, or are handed off to the theme. Additionally, ConTemplate can choose to add any files, images, or other media to RSS feeds as an attachment.
Templates are normally stored in the database but it is also possible to create disk-based templates which live in your sites directory and can be inherited across multisite installations in the same way as themes or modules.
Try the Custom Formatters module, simply make a custom formatter to render the node out exactly how you want it, then output the formatter to code or to a Feature for deployment.