Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-05-09 19:38:47

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Code review for my first plugin.

Hello plugins creators,

I’m writing my first plugin for Textpattern.
It’s a grid display for textpattern image tab.
I now, It is expected that Textpattern 4.6 offers a new interface for the Image tab, but I had a more compact display for Textpattern 4.5.*

I am a beginner in php and in creating plugin. So if someone could have time to check my code before I publish.

Thank you

tom_image_grid

Offline

#2 2014-05-09 20:23:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: Code review for my first plugin.

I’m not a Javascript expert so won’t comment on the actual code, but I will say that I really really really like the way it makes the image panel more usable.

When I started my image grid work back in 4.3.0 that never got finished, I opted for a similar sort of feel but used a select list for changing sort order and direction. That was messy and either required two drop downs (one for sort order, one for direction) or doubling up of sort parameters (id ascending, id descending, name ascending, …). Your approach of keeping the column headings is a much neater idea. Very clever because the sort order information is retained.

I also couldn’t decide how much detail to display in each cell, especially given the tag builder stuff, which took up too much space. I chose to offer a single link which popped up the builder with the first item (Textile) chosen in the tag builder popup. If you preferred HTML, for example, my plan was to remember that choice so when you next clicked the Tag Builder link, HTML would be pre-selected in the popup. That setting could carry over to any other places the drop down is utilised.

One other thing I toyed with — and I thought would be fairly successful but the AJAX facility wasn’t in core back in 4.3.0 — was to make the category name clickable. When clicked, it makes an AJAX call to request the latest Image Category list according to appropriate privilege levels and replaces the static category name with a select list from which you can alter the category or click a nearby ‘x’ to cancel the operation. Nice for rapid alterations to single images without having to jump to the edit panel. Same for the Author I’d think. That workflow has the fringe benefit that any new additions to the category list in another browser tab are immediately available in the Images panel without refreshing the page.

Anyway, those are just my random musings on how I approached it and I think it’s fantastic that you’ve made it work! I don’t know how far Phil has got with the grid stuff, but I’d love to roll some of the ideas from this plugin into core for the next version. We’ll have to wait to see what Phil says as chief designer and UX architect, but it’s a superb stepping stone. Thanks for writing the plugin.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2014-05-09 21:10:55

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Code review for my first plugin.

Code-wise, all classes, IDs and HTTP cookies added by the plugin should be prefixed with your plugin author prefix, tom_.

Offline

#4 2014-05-10 07:48:53

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Code review for my first plugin.

I have a mockup of grid image layout in 4.6 admin, just haven’t shared it yet. Got other admin side stuff to finish first. But I’ll sure check this plugin out and see if we’ve come up with similar ideas or there are any I can adopt.

Cheers.

Offline

#5 2014-05-11 00:16:33

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: Code review for my first plugin.

Nice plugin, I really like the grid view.

Offline

#6 2014-05-13 15:03:42

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Code review for my first plugin.

but I will say that I really really really like the way it makes the image panel more usable.

Nice plugin, I really like the grid view.

Thanks. It makes me happy.

@Gocom
Thank for checking my code and open issues in github.

—————

And now, what is the process to reserve prefix and create an account in textpattern.org?

Offline

#7 2014-05-13 15:53:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Code review for my first plugin.

I just upgraded your account to a plugin author as it would be good for you to post your work in the appropriate forum.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2014-05-13 17:58:58

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Code review for my first plugin.

Thanks Colak for account upgrade.

——————

I’ve a little problem with this plugin.

I add some html code for my buttons switcher with

register_callback( 'tom_image_grid_markup', "image");

But this code add buttons in images list AND image detail pages.
What is the solution for add my code only in images list page ?

Offline

#9 2014-05-20 00:02:08

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Code review for my first plugin.

sacripant wrote #280788:

What is the solution for add my code only in images list page ?

Add the step to the callback


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#10 2014-05-20 13:25:12

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Code review for my first plugin.

Plugin release. Thx to all

Offline

Board footer

Powered by FluxBB