Not a developer? Go to MovableType.com

Plugin and Theme Directory

EntrySetBasename v1.0

By Brad Choate
Posted September 11, 2008, in Utilities.

Details

ABSTRACT

This is a utility plugin to assist in setting entry basenames to the value of the dirified entry title.

WARNING: Using the <$mt:EntrySetBasename$> tag will cause Entry basenames to be changed in the blogs database. This plugin and the tag is provides is meant to be used once to set basenames and then it should be removed.

HISTORY

In MT4.2 the dirify function was updated to not remove dashes. If the phrase to dirify was:

Foo-Bar Baz

Dirify in MT4.1 would produce:

foobar_baz

Dirify in MT4.2 would produce:

foo-bar_baz

This change to the dirify function has affected urls of blogs which use a dirified entry title in the archive map, such as in this example:

archives/<$mt:EntryTitle dirify="1"$>.html

Though MT tags can be used to create archive mappings, because there is a specific tag for doing this, it is kind of a hack… albeit a popular one!

This was most-commonly used to overcome the 100 character default limit (which can be increased to 250 in Entry Settings) but could have also been lack of knowledge of how the <$mt:EntryBasename$> works.

Though MT tags can be used to create archive mappings, the entry basename was meant to be used when creating urls to the entry because the basename is created to be unique among all entries and never changes once the entry is published. A dirified entry title will change if the title of the entry changes or… if the dirify function changes. So ideally basename should be used when creating archive mappings.

  • how entry basename is created when creating an entry

There are a few limitations with basename, but since :

  • it must be 250 characters or less
  • it is limited to letters, numbers, dashes, and underscores

SOLUTION

The basic solution is to populate past basenames with previously dirified entry titles.

By hand this could be difficult—but thanks to Mr. Brad Choate—there is a super simple utility plugin to help!

WARNING: But please be warned, using the <$mt:EntrySetBasename$> tag will cause Entry basenames to be changed in the blogs database. This plugin and the tag is provides is meant to be used once to set basenames and then it should be removed.

  1. As always when performing massive changes to data, create a backup in the case that you need to revert.
  2. Install EntrySetBasename plugin.

    $MT_HOME/
        plugins/
            EntrySetBasename
    
  3. Set basename length to 250 (or desired length) in Preferences > Entry Settings

  4. Update archive mappings to use basename. Thus this mapping:

    archives/<$mt:EntryTitle dirify="1"$>.html
    

    would become:

    archives/<$mt:EntryBasename$>.html
    
  5. Create an index template named “Dirify” and paste the following code:

    <ul>
        <$mt:setvar name="first_entry_id_in_4_2" value="12345"$>
        <mt:Entries lastn="99999">
            <$mt:EntryID setvar="entry_id"$>
            <mt:if name="entry_id" lt="$first_entry_id_in_4_2">
                <$mt:EntryTitle dirify="1" setvar="new_dirified_title"$>
                <$mt:EntryTitle regex_replace="/-/g","" dirify="1" setvar="old_dirified_title"$>
                <mt:if name="new_dirified_title" ne="$old_dirified_title">
                    <li>
                        <$mt:EntrySetBasename value="$old_dirified_title" test="1"$>
                    </li>
                </mt:if>
            </mt:if>
        </mt:Entries>
    </ul>
    

    This code will output a page listing the entries in your blog if the entry id is less than the id of the first entry created in MT4.2 and if the title dirified previous to MT4.2 and dirified in MT4.2 are not the same. For each matching entry the basename will be set to the value specified on the mt:EntrySetBasename tag, if the test attribute is not set to 1.

  6. If you have created posts since upgrading to MT4.2, find the id of the first post created in MT4.2 and enter the id number as the value for the variable “firstentryidin4_2”.

  7. If you have more than 99999 entries, update the lastn value of the <$mt:Entries$> loop to be higher than the number of entries you have in your blog.

  8. Save the “Dirify” index template with the code above and modifications in the last two steps and publish it. Because the EntrySetBasename tag has a test attribute set to 1, no basenames will be rewritten.

  9. Review the published output from the Dirify index template to review the changes that will be made. They will look similar to this:

    • Entry #1921, ‘NY-Times Shocker’ basename set to ‘nytimes_shocker’

    If you’d like to have more testing data (and a link to directly edit the entry) add these lines before the <$mt:EntrySetBasename$> tag inside the HTML list item (placing after the tag will effect output of the <$mt:EntryBasename$> tag):

    EntryBasename: <$mt:EntryBasename$><br />
    EntryTitle: <$mt:EntryTitle$><br />
    new_dirified_title: <$mt:Var name="new_dirified_title"$><br />
    old_dirified_title: <$mt:Var name="old_dirified_title"$><br />
    <a href="<$mt:AdminScript$>?__mode=view&amp;_type=entry&amp;id=<$mt:EntryID$>">Edit Entry</a><br />
    
  10. Once you are ready to set all the basenames to the pre-MT4.2 dirified title, remove the “test” argument from the mt:EntrySetBasename tag and republish the Dirify index template. So that

    <$mt:EntrySetBasename value="$old_dirified_title" test="1"$>
    

    becomes:

    <$mt:EntrySetBasename value="$old_dirified_title"$>
    
  11. Uninstall the plugin and delete the Dirify index template.

  12. Republish your Blog.

Versions

  • Version 1.0 - Initial Release - Tag code by Brad Choate. Documented and tested by Beau Smith.

Compatibility

Movable Type versions: 4.3


Back

32 Comments

supert

supert on March 7, 2017, 11:05 p.m. Reply

Thanks for the development of this plugin works perfectly

novinhas xvideos xvideos videos pornô

linkerseo

linkerseo on April 9, 2018, 2:20 p.m. Reply

Hello there! This is my first visit to your blog! We are a group of volunteers and new activities in a similar specialty. Blog gave us valuable data to work. You have completed an astonishing activity! Stephen Pierce

james jack

james jack on April 11, 2018, 10:18 a.m. Reply

page where it is cool described.    <a href="http://www.starbuild.it/professionisti/PI/pisa/ristrutturazioni-edili">Preventivo ristrutturazione</a>
james jack

james jack on April 13, 2018, 3:50 a.m. Reply

I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog. Security Berlin

Tim Connor

Tim Connor on April 14, 2018, 8:25 p.m. Reply

Thanks for the great article! www.carpetcleanercolumbia.com

Tim Connor

Tim Connor on April 14, 2018, 8:48 p.m. Reply

Thanks for the great article! www.carpetcleanercolumbia.com

linkerseo

linkerseo on April 20, 2018, 12:27 p.m. Reply

We cover all the necessary services to bring you from a business concept idea to a concrete successful Initial Coin Offering. With and thanks to our business partners, we customize and manage the entire process to let your ICO successful, safe, and compliant accordingly. ico management

stylishfloor

stylishfloor on April 28, 2018, 1:30 a.m. Reply

Thanks for this plugin!

church in Wake Forest

linkerseo

linkerseo on May 1, 2018, 2:44 p.m. Reply

If your looking for Online Illinois license plate sticker renewals then you have need to come to the right place.We offer the fastest Illinois license plate sticker renewals in the state!..Zwembaden

pioneerseo

pioneerseo on May 16, 2018, 6:19 p.m. Reply

Uncommon tips and clear. This will be to a great degree supportive for me when I get a chance to start my blog. web proxy

pioneerseo

pioneerseo on May 18, 2018, 10:14 a.m. Reply

I will really appreciate the writer’s choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more. Silsila Badalte Rishton Ka

pioneerseo

pioneerseo on May 18, 2018, 6:07 p.m. Reply

Ordina su 1food.it il tuo panino preferito a Milano, scegli il tuo preferito tra una lista delle migliori paninerie e questo ti verrà consegnato a casa! Hamburger a domicilio

pioneerseo

pioneerseo on May 19, 2018, 3:17 p.m. Reply

Astounding, this is awesome as you need to take in more, I welcome to This is my page. cedar roofing contractor

pioneerseo

pioneerseo on May 25, 2018, 6:01 p.m. Reply

Great to end up going to your weblog once more, it has been a long time for me. Pleasantly this article i’ve been sat tight for so long. I will require this post to add up to my task in the school, and it has identical subject together with your review. Much obliged, great offer. weight loss supplements

pioneerseo

pioneerseo on May 26, 2018, 12:21 a.m. Reply

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. ΘΩΡΑΚΙΣΜΕΝΕΣ ΠΟΡΤΕΣ ΤΙΜΕΣ

Fitness Guru

Fitness Guru on May 26, 2018, 12:37 p.m. Reply

Great work really! We wish you all the best and to us as well! We are helping business around the world, and our latest was with a fitness website. They have written a review of one of the best and most popular weight loss supplements in the world, it is called PhenQ. Their review is called PhenQ Review. In this PhenQ Review they are detailing the ingredients, pros and cons, side effects, and whether you should buy it or not.

pioneerseo

pioneerseo on May 28, 2018, 12:52 a.m. Reply

I can give you the address Here you will figure out how to do it accurately. Read and compose something great. windows 10 theme download

pioneerseo

pioneerseo on May 29, 2018, 11:50 p.m. Reply

I can give you the address Here you will figure out how to do it accurately. Read and compose something great. ganhar seguidores no instagram gratis

pioneerseo

pioneerseo on June 1, 2018, 1:12 p.m. Reply

This post is very simple to read and appreciate without leaving any details out. Great work! nifty share price

pioneerseo

pioneerseo on June 2, 2018, 10:34 a.m. Reply

It is awesome to have the chance to peruse a decent quality article with valuable data on subjects that bounty are intrigued one.I agree with your decisions and will excitedly anticipate your future updates. Laverdaddesnuda.com

pioneerseo

pioneerseo on June 4, 2018, 4:02 p.m. Reply

We bring nature to you, wherever your workplace, whatever your space, we create and maintain indoor and outdoor planting schemes for offices, hotels, shops, and restaurants. We provide Landscaping services in Kochi, Kerala. We design, create & maintain Vertical gardens, Green walls and Terrace gardens. Contact us for all your Indoor and Outdoor garden creation and maintenance. Chainsaw’s, Weed Cutters, Blowers Online in India

pioneerseo

pioneerseo on June 5, 2018, 4:13 p.m. Reply

This post is very simple to read and appreciate without leaving any details out. Great work! fcra

pioneerseo

pioneerseo on June 6, 2018, 5:08 p.m. Reply

کاغذ دیواری تیراژه هارمونی دنیایی از طرح و رنگ با بالاترین قیمت و مناسبترین کیفیت . انواع <a href="http://tirazheharmony.com">کاغذ دیواری</a> برای کاربرد های مختلف و طرح های کاغذ دیواری متنوع مناسب برای همه سلیقه ها
pioneerseo

pioneerseo on June 6, 2018, 5:18 p.m. Reply

With such gigantic quantities of books and articles coming up to offer way to benefit online field and perplexing peruser significantly more on the bona fide technique for winning money, usa visit visa

pioneerseo

pioneerseo on June 9, 2018, 3:40 p.m. Reply

You should essentially phenomenal also strong guidance, which implies take note: ΑΠΟΦΡΑΞΕΙΣ ΑΠΟΧΕΤΕΥΣΕΩΝ ΚΥΨΕΛΗ

pioneerseo

pioneerseo on June 13, 2018, 4:01 p.m. Reply

Grandbetting giris adresi, Grand Betting yeni giris adresi ve Grandbet hakkinda bilgilendirme.

pioneerseo

pioneerseo on June 15, 2018, 8:16 a.m. Reply

Exceptionally decent blog and articles. I am realy extremely cheerful to visit your blog. Presently I am discovered which I really need. I check your blog ordinary and attempt to take in something from your blog. Much obliged to you and sitting tight for your new post. media maison

pioneerseo

pioneerseo on June 15, 2018, 1:55 p.m. Reply

Vancouver SEO Agency offers complete business listings that let you have dofollow links. This is great for your business and drives up your sites rankings. SEO Vancouver

pioneerseo

pioneerseo on June 16, 2018, 10:58 a.m. Reply

I no doubt valuing every last piece of it. It is a staggering site and better than average bestow. I have to thankful. Awesome work! All of you do an inconceivable blog, and have some exceptional substance. Continue doing amazing. personal alarms

pioneerseo

pioneerseo on June 18, 2018, 12:47 p.m. Reply

I no doubt valuing every last piece of it. It is a staggering site and better than average bestow. I have to thankful. Awesome work! All of you do an inconceivable blog, and have some exceptional substance. Continue doing amazing. Enemy Revenge Spells

pioneerseo

pioneerseo on June 19, 2018, 7:14 a.m. Reply

Intriguing post. I Have Been pondering about this issue, so a debt of gratitude is in order for posting. Entirely cool post.It ‘s extremely exceptionally decent and Useful post.Thanks pinoytv

Leave a Comment