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

How does EE generate unique URL titles?

Development and Programming

vosSavant's avatar
vosSavant
380 posts
about 14 years ago
vosSavant's avatar vosSavant

This may be more of a general SQL question, but I figured maybe one of the EE tech guys would have an answer since it deals with EE.

I’m using EE on a fairly advanced custom app and I have come across the need to generate channel entries manually. I know that URL titles need to be unique, and that whenever a new channel entry is created, you need to make sure the URL title is unique (usually by appending a number).

One approach that I’ve thought of – and that works – is to create an array of existing entries, then compare the new entry’s title to each one. If it matches an existing URL title, append a number.

However, this seems really inefficient. I doubt EE does it this way. So…how does EE generate unique URL titles? Can I use something like INSERT IGNORE? Should I make use of the Channel Entries API? (right now I’m doing it manually with PHP).

Thanks!

       
Shane Eckert's avatar
Shane Eckert
7,174 posts
about 14 years ago
Shane Eckert's avatar Shane Eckert

Hello Ryan,

This is a bit outside of support, but I do appreciate your question.

I would like to move this to Development and Programming, you will get some great insight into this and there will be a lot more eyes on the question.

Does that sound good?

Cheers,

       
vosSavant's avatar
vosSavant
380 posts
about 14 years ago
vosSavant's avatar vosSavant

Sounds great, thanks.

       
Bhashkar Yadav's avatar
Bhashkar Yadav
727 posts
about 14 years ago
Bhashkar Yadav's avatar Bhashkar Yadav

EE uses url helper to generate URL title. As you know it checks if that url_title is already taken by creating new url_title with appending a number.

it would be best way to use Channel Entries API for new entries.

       
vosSavant's avatar
vosSavant
380 posts
about 14 years ago
vosSavant's avatar vosSavant

Thanks Bhashkar. Since I’ve posted I’ve had some time to tinker with the Channel Entries API and it’s much, much cleaner than the manual stuff I was doing before. I don’t have to worry about duplicating URL titles and I can use less code.

Much appreciated!

       

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.