Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2010-02-17 21:41:10

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

Re: Upload files during writing a new article

redbot, on my site each article should contain different files and images (like screenshots). It’s important that files are stored on my sites, but if I give all users ability to publish their files it will lead to real mess – published files and pending articles. So I want to moderate each article and file and if a theme of the article is acceptable, I will publish the article and publish its files (users are allowed to browse all published files, because usually they know what they want and it’s faster to look throug list of files and find something interesting for them).

And, of course, it would be great if during writting a article user wasn’t made click to Files tab for adding one new. So, it looks like adding a new post on forum – if you want to add a archive – you can do it without going to another page.

Last edited by WeibRabe (2010-02-17 21:44:09)


Disce, sed a doctis, indoctos ipse doceto

Offline

#12 2010-02-18 16:31:01

kireol
New Member
From: Michigan
Registered: 2010-02-18
Posts: 1
Website

Re: Upload files during writing a new article

This is hard to do in drupal as well. Which is why i’m shopping for a new cms. Thanks for the info


Working Hard Playing Hard

Offline

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

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 562
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: 562
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:
!http://img517.imageshack.us/img517/8434/cfh.gif!

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
From: Virton (BE)
Registered: 2004-10-01
Posts: 752
Website

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: 562
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

Board footer

Powered by FluxBB