Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-02-19 10:42:58

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Upload files during writing a new article

WeibRabe wrote:

And, of course, it would be great if during writting a article user wasn’t made click to Files tab for adding one new.

Not a problem!
1. Create a custom field (lets call it “File number”)
2. Use a lightbox script like colorbox
upload the files of Colorbox script to your server lets say to “/scripts/”
3. Now for adding codes into the Write tab you can Install the bot_write_tab_customize plugin, or edit the txplib_head.php file.

4. Add this code inside the plugin / txplib_head.php:

<script type="text/javascript" src="/scripts/jquery.colorbox.js"></script>
<link rel="stylesheet" href="/scripts/colorbox.css" type="text/css" media="screen" />
<script type="text/javascript">
$(document).ready(function(){
	$("label[for='custom-7']").replaceWith("<label for='custom-7'>File ID # [<a rel='upload_file' href='/textpattern/index.php?event=file'>upload</a>]</label>");
	$("a[rel='upload_file']").colorbox({width:"95%", height:"95%", iframe:true, overlayClose:false});
</script>

Change custom-7 to your custom field number,
and /textpattern/index.php?event=file to something else if you use a sub folder for your TXP site.

And that’s it!
You can upload manage do what ever you want without getting out or open a new tab in the Write tab.
You can do the same for other stuff like for Images, Categories, Google maps…

Offline

#14 2010-02-27 13:11:40

WeibRabe
Member
Registered: 2010-02-16
Posts: 10
Website

Re: Upload files during writing a new article

THE BLUE DRAGON, thank for your advice. But I’ve got some troubles with plugin and txlib_head.php (which is located in textpattern/lib/). After uploading colorbox files and changing txlib_head.php, I haven’t seen any differences.. Just labels with textbox (custom-1, custom-2).


Disce, sed a doctis, indoctos ipse doceto

Offline

#15 2010-02-27 14:13:02

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Upload files during writing a new article

Which custom field number do you use (or want to use) for the file ID# ?
the code I post above it’s for custom field #7
and you must first set this custom field in the “Advanced” tab under “Admin » Preferences”
just name it something like “file_upload” or as you wish to ( beside of all these names ).
after that you go and change the custom field number in this code:

<script type="text/javascript">
$(document).ready(function(){
	$("label[for='custom-7']").replaceWith("<label for='custom-7'>File ID # [<a rel='upload_file' href='/textpattern/index.php?event=file'>upload</a>]</label>");
	$("a[rel='upload_file']").colorbox({width:"95%", height:"95%", iframe:true, overlayClose:false});
</script>

Change label[for='custom-7'] and <label for='custom-7'> to the number of your custom field.

In the end it will look like this:

This is just changing the data in the <label> tag on the fly, but it’s not really changing your field name
so you will continue to use your real field name like “file_upload” in your articles forms
( <txp:custom_field name=“file_upload” /> )

Last edited by THE BLUE DRAGON (2010-02-27 14:31:06)

Offline

#16 2010-02-27 17:05:05

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: Upload files during writing a new article

Hello Gil !

Awesome …
It would be fine to put your “tutorial” on txptips !

Offline

#17 2010-02-27 18:43:48

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: Upload files during writing a new article

jpdupont wrote:

Awesome …
It would be fine to put your “tutorial” on txptips !

I agree.
If it’s that easy to add upload capabilities to the Write tab, it should be featured prominently.

Many users have asked for this.

Offline

#18 2010-02-27 19:18:59

WeibRabe
Member
Registered: 2010-02-16
Posts: 10
Website

Re: Upload files during writing a new article

THE BLUE DRAGON, I’m sure that I made a mistake, so I’ll describe in detail what I did:
1. Went to Admin -> Preference and named custom field 3 ‘file_upload’
2. Changed all ‘custom-7’ to ‘custom-3’ in the code you gave.
3. Placed the code in lib/txplib_head.php (function pagetop($pagetitle,$message=”“))
4. Reloaded Write page… and nothing happened.

EDIT:

I found the mistake. You code should be like this:

<script type=“text/javascript” src=“textpattern.js”></script>
<script type=“text/javascript”> $(document).ready(function(){ $(“label[for=‘custom-3’]”).replaceWith(“<label for=‘custom-3’>File ID # [<a rel=‘upload_file’ href=’/textpattern/index.php?event=file’>upload</a>]</label>”); $(“a[rel=‘upload_file’]”).colorbox({width:“95%”, height:“95%”, iframe:true, overlayClose:false});});
</script>

But.. It doesn’t work as I need. After clicking ‘upload’, the iframe opens where I see the Files tab.

Last edited by WeibRabe (2010-02-27 19:34:46)


Disce, sed a doctis, indoctos ipse doceto

Offline

#19 2010-02-27 21:34:45

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Upload files during writing a new article

WeibRabe wrote:

But.. It doesn’t work as I need. After clicking ‘upload’, the iframe opens where I see the Files tab.

That was the point, to open the Files tab or whatever page,
inside or outside txp without geting out from the Write tab in a lightbox instead of in a new window/tab.
You and other users can now upload/delete/manage the files.

About your privacy question, sorry I don’t know how to help you.
But at least you got one thing to work ;)

Offline

#20 2010-02-27 22:08:35

WeibRabe
Member
Registered: 2010-02-16
Posts: 10
Website

Re: Upload files during writing a new article

THE BLUE DRAGON, thank you very much.
I think I will try to use something like that – http://plugins.jquery.com/project/MultiFile/ and integrate it with files/image system in TextPattern.


Disce, sed a doctis, indoctos ipse doceto

Offline

#21 2010-02-27 22:43:01

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Upload files during writing a new article

For images try jbx_multiple_image_upload 0.4 or ebl_upload
For files try to integrate the uploadify script

Offline

#22 2010-02-27 23:18:38

WeibRabe
Member
Registered: 2010-02-16
Posts: 10
Website

Re: Upload files during writing a new article

THE BLUE DRAGON, I really don’t know how much I will say you thank:).

I’ve got a problem with jbx_multiple_image_upload 0.4, I installed the plugin, activated it.. and coudn’t find any place where the plugin appeared:). Only settings in Extension.

About uploadify – I have already downloaded this script (and other scripts, trying to choose the best one).

Last edited by WeibRabe (2010-02-27 23:19:08)


Disce, sed a doctis, indoctos ipse doceto

Offline

#23 2010-02-28 09:44:17

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 619
Website

Re: Upload files during writing a new article

about jbx_multiple_image_upload,
log into your site using FTP and check out if there is a folder name “upload” into your “images” folder
and if it’s containing the plugin script files.
if it’s there, so you should see the new upload form in the Images tab.
if there is no folder name “upload” into “images” so deactive the plugin, remove it and install it again
in hope this time it will work and create the folder for you with the files inside it.
You will notice that jbx_multiple_image_upload also use the uploadify script.
For me the plugin doesn’t work because I’m getting security errors while uploading, but for others it is works good!

Last edited by THE BLUE DRAGON (2010-02-28 09:46:34)

Offline

Board footer

Powered by FluxBB