September 2008 Archives

Increase Basename Length for SEO URLs

| 2 Comments

Well authored urls make for good SEO. One the simplest ways to do this is to write good titles to your entries and then MT will dirify the title to create a basename from which the url to the entry is created. But if your entry title is longer than 100 characters, the rest of the url is clipped.

Good news! Basename can be increased to 250 characters. As it seems that most people would prefer unclipped urls to long urls, I added a feature request to increase the default to the max of 250 characters. Then if a user prefers to have smaller urls, they can modify this setting.

To change your default, navigate to Preferences > Entry Settings, and change Basename Length to your desired length.

Entry Settings - Adventures in Movable Type | Movable Type Pro

Wondering how to customize the Global Templates “Profile Edit Form” or the “Registration Form”? Here’s a few options.

Basic reordering of custom fields is possible on the edit profile page in the MT app. Using the “Reorder Fields” in the “related content” sidebar.

If you want to intersperse custom fields between default fields it’s a little more trickey; by default all built-in fields are output and then all custom fields are output in the order specified on the edit profile page.

The <mt:AuthorCustomFields> tag should be used for this but as of MT4.2 I couldn’t get it to work on the edit profile or registration form, so for now you can use the same loop that currently outputs the custom fields, but limit the output with an <mt:if> tag. Here’s an example of how you can do it…

Description

Use three loops each containing an conditional tag (if or unless) to limit the output of the loop by custom field basename. The first and second loops limit by checking to see if the basename is equal to a value. The third loop outputs all fields except the the two I’ve specified (if fields are duplicated on the form the html will be invalid and only the second input’s value will be saved)

Example

Thi example uses the custom fields “Level” and “Bio”. You may place each loop anywhere in the Edit Profile template’s form.

<mt:Loop name="field_loop">
   <mt:If name="__first__">
   <input type="hidden" name="_type" value="author" id="obj_type" />
   <input type="hidden" name="customfield_beacon" value="1" id="customfield_beacon" />
   </mt:If>
   <mt:if name="basename" eq="level">
   <!-- start-customfield_<$mt:Var name="basename"$> -->
   <mtapp:setting
   id="$field_id"
   label="$name"
   hint="$description"
   shown="$show_field"
   show_hint="$show_hint"
   required="$required">
   <$mt:Var name="field_html"$>
   </mt:App:Setting>
   <!-- end-customfield_<$mt:Var name="basename"$> -->
   </mt:if>
</mt:Loop>

<!-- Default field here -->

<mt:Loop name="field_loop">
   <mt:If name="__first__">
   <input type="hidden" name="_type" value="author" id="obj_type" />
   <input type="hidden" name="customfield_beacon" value="1" id="customfield_beacon" />
   </mt:If>
   <mt:if name="basename" eq="bio">
   <!-- start-customfield_<$mt:Var name="basename"$> -->
   <mtapp:setting
   id="$field_id"
   label="$name"
   hint="$description"
   shown="$show_field"
   show_hint="$show_hint"
   required="$required">
   <$mt:Var name="field_html"$>
   </mt:App:Setting>
   <!-- end-customfield_<$mt:Var name="basename"$> -->
   </mt:if>
</mt:Loop>

<!-- Default field here -->

<mt:Loop name="field_loop">
   <mt:If name="__first__">
   <input type="hidden" name="_type" value="author" id="obj_type" />
   <input type="hidden" name="customfield_beacon" value="1" id="customfield_beacon" />
   </mt:If>
   <mt:unless name="basename" like="(bio|level)">
   <!-- start-customfield_<$mt:Var name="basename"$> -->
   <mtapp:setting
   id="$field_id"
   label="$name"
   hint="$description"
   shown="$show_field"
   show_hint="$show_hint"
   required="$required">
   <$mt:Var name="field_html"$>
   </mt:App:Setting>
   <!-- end-customfield_<$mt:Var name="basename"$> -->
   </mt:unless>
</mt:Loop>

Aaron Vanderzwan offers a similar solution and Elise summarized the solution on LearningMT4.com

MTML Code in Entries or Pages

| No Comments

You want a page with a title and a few paragraphs… but you also want a list of entries as a part of the page. How to do it?

You can use the mteval global modifier, but in the note I added there due to the way MT is optimized to publish, using the mteval global modifier isn’t really an option for most cases.

But there is a better way. The concept is to use an index template but to build the content of the template by combining content from a page and from entries.

Here’s how to create a page for entries tagged as events:

  1. Create a page titled “Events”.

    Add the body text “These are our events”.

    Add the tag “@eventpage”.

  2. Create a few entries with sample event info and add the tag “event”.

  3. Create a new index template called “Events” and set the output file as events.html.

    In the body of the template add this code to list the most recent 10 events tagged with the private tag “@event”:

    <mt:Pages tag="@eventpage" lastn="1">
        <h1><$mt:EntryTitle$></h1>
        <$mt:EntryBody$>
    </mt:Pages>
    <ul>
    <mt:Entries tag="event" lastn="10">
        <li><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></li>
    </mt:Entries>
    </ul>
    
  4. Save the index template… and then publish the index template.

That’s it. =)