Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
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
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
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
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
Re: txp_image hack/improvement
Changing the image category for multiple images at once will work in TXP 4.0.7.
Offline
Re: txp_image hack/improvement
Good news ruud !
françois
Offline