Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-12 08:33:10

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

txp_image hack/improvement

Hello,

I’m working on a hack/improvement in the file txp_image.php.
The goal is to add the possibility to quick modify the name, alt, legend, category, date of an image right in the image_list : like this screen shot (in french). Then, I can use <txp:image_index c="sky" sort="date DESC" /> and reorder my images only with a new date (like we can do in the article edit page with more).

It works : I can modify everything in the image list : name, alt, legend, category, date, but my dropdown menu of categories doesn’t select the current image category (see the screen shot) and is set to none, so if I click “save”, the category is set to “none”.

Here’s the peace of code that I use to build this dropdown menu :

n.graf('<label for="image-category">'.gTxt('image_category').'</label>'.br. treeSelectInput('category', getTree('root', 'image'), $category, 'image-category')).

If someone have an idea to help me : thanks.


françois

Offline

#2 2008-06-12 08:44:28

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: txp_image hack/improvement

Does your query actually work (add debug argument)? safe_field() might be a better choice, since you only need one field.

Offline

#3 2008-06-12 10:32:13

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: txp_image hack/improvement

jm a écrit:

since you only need one field.

I don’t understand why I “only need one field” : I need the dropdown list and the current image category to be selected.
I need to look carefully at function treeSelectInput() and to understand how it works.


françois

Offline

#4 2008-06-12 17:39:06

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: txp_image hack/improvement

thanks jm : I think I’ve understand now what you mean with the safe_field() !

Now my code works, even if it needs a few improvments.


françois

Offline

#5 2008-06-12 21:55:49

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: txp_image hack/improvement

Let me show you the result : screen shot
The next stept will be to separate inputs for Year-Month-Day…, for now I can display the date in these inputs but I can’t submit them or they turn to 0000.00.00.00 :-(

EDIT : I’ve added an anchor at each row, then when you save something, you stay on the image you’ve just modified and you’re not sent at the top of the page ;-)

Last edited by fpradignac (2008-06-16 09:03:47)


françois

Offline

#6 2008-06-13 09:52:03

jelle
Member
Registered: 2006-06-07
Posts: 165

Re: txp_image hack/improvement

This looks good! How about ID sorting? Like an up/down button for moving it up down on the list. This way a user can simply sort images without having to change the page source.

Last edited by jelle (2008-06-13 09:53:16)

Offline

#7 2008-06-13 10:07:42

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: txp_image hack/improvement

Nice hack :) But it’s better to make it like plugin. And, the best was – add ajax :)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#8 2008-06-13 10:08:39

jelle
Member
Registered: 2006-06-07
Posts: 165

Re: txp_image hack/improvement

the_ghost wrote:

add ajax :)

ooohhh…..drop & drop sorting!

Offline

#9 2008-06-13 12:59:56

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: txp_image hack/improvement

the_ghost a écrit:

Nice hack :) But it’s better to make it like plugin. And, the best was – add ajax :)

Oh yes ! But it was more simple for me, and I don’t know anything about ajax.

But Victor, if you have the knowledge, it can be a very important plugin for people dealing with photogallery and so on.

Last edited by fpradignac (2008-06-13 13:42:21)


françois

Offline

#10 2008-06-13 15:08:20

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: txp_image hack/improvement

One thing to say here :

<txp:image_index c="sky" /> all the images of the sky category are “sortby” name and “sortdir” ASC : sort=“name ASC” (default values)

But <txp:image_index /> allow a lot of sorting :
<txp:image_index c="sky" sort="id DESC" />
<txp:image_index c="sky" sort="date ASC" />
etc.

By default, with sort=“name ASC”, we can reorder our images simply by renaming images : 1-blue.jpg, 2-red.jpg, etc.

My hack is just here to quickly rename, change the date or the category directly in the image_list, without having to edit the image.


françois

Offline

#11 2008-06-13 15:14:34

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: txp_image hack/improvement

Changing the image category for multiple images at once will work in TXP 4.0.7.

Offline

#12 2008-06-13 15:26:15

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: txp_image hack/improvement

Good news ruud !


françois

Offline

Board footer

Powered by FluxBB