We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Atozee Extension

Development and Programming

Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

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?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
18 years ago
Lisa Wess's avatar Lisa Wess

wiki’d twice. Thank you.

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

haha, it’s beer not bear 😉

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
18 years ago
Lisa Wess's avatar Lisa Wess

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. =)

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

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.

       
Derek Jones's avatar
Derek Jones
7,561 posts
18 years ago
Derek Jones's avatar Derek Jones

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.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
18 years ago
ExpressionEngineer's avatar ExpressionEngineer

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..

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

Thanks Andy, and Derek for your suggestions.

       
mattbrighton's avatar
mattbrighton
50 posts
18 years ago
mattbrighton's avatar mattbrighton

Could you localize it for UK = atozed ? 😉

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
18 years ago
Ingmar Greil's avatar Ingmar Greil

The only international way would be a2z, where pronounciation is left as an excercise to the reader 😊

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

come on people, it took me close to 2 minutes to think of a name with ‘ee’ in there.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
18 years ago
Ingmar Greil's avatar Ingmar Greil

Wow, I totally failed to realise/appreciate that… Well done, in this case.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
18 years ago
ExpressionEngineer's avatar ExpressionEngineer

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?

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

Andy I think that’s a much better idea. Unless anyone suggests otherwise in the meantime I’ll update the extension later today.

       
ignite's avatar
ignite
149 posts
18 years ago
ignite's avatar ignite

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”?

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.