Atozee Extension
Posted: 06 January 2007 11:03 AM
[ Ignore ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
I just knocked up a quick extension to make it easier to create A to Z indexes of entries.
It creates a new column in exp_weblog_titles and adds the first character of the entry’s title.
You get a new parameter “title_alpha” to add to your exp:weblog:entries tag. Example:
{exp : weblog : entries weblog = "showcase|blog|features" title_alpha = "{segment_3}" dynamic = "off" } or {exp : weblog : entries weblog = "showcase|blog|features" title_alpha = "a|b|c" dynamic = "off" }
You can see it in action here . Just change the third segment to a letter to filter. There’s no support for foreign characters.
I’ve tested it on a couple of sites without problems but don’t try it on anything critical until I’ve gained some feedback.
Any suggestions for improvement?
File Attachments
Signature
Celebrating again soon.
Posted: 06 January 2007 11:21 AM
[ Ignore ]
[ # 1 ]
Moderator
Total Posts: 32037
Joined 05-14-2004
Signature
Posted: 06 January 2007 11:25 AM
[ Ignore ]
[ # 2 ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
haha, it’s beer not bear
Signature
Celebrating again soon.
Posted: 06 January 2007 11:36 AM
[ Ignore ]
[ # 3 ]
Moderator
Total Posts: 32037
Joined 05-14-2004
I totally knew that. I blame misplacing beer with bear on WoW. *whistles*
This is why other people should be adding to the wiki. See? Oooh. =)
Signature
Posted: 06 January 2007 11:53 AM
[ Ignore ]
[ # 4 ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
You’re just too quick for us Lisa
BTW, the only reason I say don’t try it on critical stuff now is that when the extension is enabled it runs through all your entries and adds the first character to the title_alpha column. I could probably improve the performance of this query as I’m not sure how it’ll handle sites with 1000s of existing entries.
Signature
Celebrating again soon.
Posted: 06 January 2007 12:52 PM
[ Ignore ]
[ # 5 ]
Administrator
Total Posts: 15232
Joined 06-03-2002
I would probably prefix the new column name. It’s not likely that we will add a column with that name, but by prefixing it with some something short and unique, you can be more assured that you are protected against potential collision, not only with first party changes, but with other third party add-ons a user might be using. And yes, one query per entry, all at once, is probably not the best implementation. As a matter of fact, I believe that you could do this with a single query, using MySQL’s built in string functions.
Signature
Posted: 07 January 2007 10:08 AM
[ Ignore ]
[ # 6 ]
Research Assistant
Total Posts: 560
Joined 07-22-2004
How about
UPDATE exp_weblog_titles SET title_alpha = LEFT ( title , 1 );
?
Edit: I’d probably add either LOWER() or UPPER() to enforce one character case..
Signature
ExpressionEngineer - custom solutions for EE
I ♥ EE
Posted: 07 January 2007 10:40 AM
[ Ignore ]
[ # 7 ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
Thanks Andy, and Derek for your suggestions.
Signature
Celebrating again soon.
Posted: 07 January 2007 04:20 PM
[ Ignore ]
[ # 8 ]
Lab Assistant
Total Posts: 143
Joined 07-21-2006
Could you localize it for UK = atozed ?
Signature
// matthanson.net
// twitter
Posted: 07 January 2007 04:23 PM
[ Ignore ]
[ # 9 ]
Moderator
Total Posts: 13905
Joined 05-15-2004
The only international way would be a2z, where pronounciation is left as an excercise to the reader
Signature
Everything will be good in the end. If it’s not good, it’s not the end.
Posted: 08 January 2007 04:01 AM
[ Ignore ]
[ # 10 ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
come on people, it took me close to 2 minutes to think of a name with ‘ee’ in there.
Signature
Celebrating again soon.
Posted: 08 January 2007 05:01 AM
[ Ignore ]
[ # 11 ]
Moderator
Total Posts: 13905
Joined 05-15-2004
Wow, I totally failed to realise/appreciate that… Well done, in this case.
Signature
Everything will be good in the end. If it’s not good, it’s not the end.
Posted: 08 January 2007 05:17 AM
[ Ignore ]
[ # 12 ]
Research Assistant
Total Posts: 560
Joined 07-22-2004
Hm.. come to think of it, I probably wouldn’t create another column unless its really neccessary for performance.
I’ll have to extend Derek’s line of though here, it’s potentially hasardous to alter the core tables, compared to adding a cpu-cycle and a half to each query.
SELECT entry_id FROM exp_weblog_titles WHERE LEFT ( LOWER ( title ), 1 ) = 'a' ;
What are your thoughts on this?
Signature
ExpressionEngineer - custom solutions for EE
I ♥ EE
Posted: 08 January 2007 05:55 AM
[ Ignore ]
[ # 13 ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
Andy I think that’s a much better idea. Unless anyone suggests otherwise in the meantime I’ll update the extension later today.
Signature
Celebrating again soon.
Posted: 11 January 2007 03:51 PM
[ Ignore ]
[ # 14 ]
Research Assistant
Total Posts: 402
Joined 03-17-2006
smallbeer, Is the currently linked extension the updated version?
edit: Also does dynamic have to be set to “off” or am I able to use this in conjunction with pagination which seems to require dynamic to be set to “on”?
Posted: 15 January 2007 01:08 PM
[ Ignore ]
[ # 15 ]
Research Assistant
Total Posts: 402
Joined 03-17-2006
Anybody know if the linked extension is the current version? I’m having trouble getting it to work.
Posted: 15 January 2007 01:59 PM
[ Ignore ]
[ # 16 ]
Research Assistant
Total Posts: 544
Joined 01-05-2005
No the attached file isn’t the updated version. I’ve been too busy the past few days. It won’t take long though so I’ll try find the time tomorrow.
And no, the dynamic parameter doesn’t necessarily have to be set to ‘off’.
Signature
Celebrating again soon.
Posted: 16 January 2007 09:30 AM
[ Ignore ]
[ # 17 ]
Research Assistant
Total Posts: 402
Joined 03-17-2006
smallbeer - 15 January 2007 01:59 PM
No the attached file isn’t the updated version. I’ve been too busy the past few days. It won’t take long though so I’ll try find the time tomorrow.
Ok, that could explain why I’m having trouble getting it to work. I’m looking forward to the updated version.
smallbeer - 15 January 2007 01:59 PM
And no, the dynamic parameter doesn’t necessarily have to be set to ‘off’.
Good to know, thanks.