Afshin Haghighatnia

How to have some other characters in entry basename automatically written

Vote 0 Votes

Hi there.

Movable type automatically fills the Basename field while writing the title of an entry. I want to know that how can I have some other characters to be written automatically while writing that character in the Title field. I think this capability is brought by a javascript file, but I don,t know how and where to edit.

Would you please help me?!

Reported on Movable Type 5

16 Replies

| Add a Reply
  • Hi Afshin,

    The function involved on that is called rebasename.

    You could find it under:
    /tmpl/cms/edit_entry.tmpl

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Daily Movable Type Consultant

    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/
    ----------------------------------

    Open Melody Demo
    http://www.openmelodydemo.org/

  • Afshin Haghighatnia

    I just want to add support for some unicode characters.

    I had the same situation with my own written code in PHP and Javascript. Of course, it has been solved using the code below :

    <script type="text/javascript">  
           function autofill()
           {
               var str = addpage.pageTitle.value;
               str = str.replace(/[^Ø¢-ÛŒa-zA-Z0-9]+/g,'-');
               addpage.pageBasename.value= str;
           } 
        </script>
    

    I mean by adding "آ-ی" beside a-zA-Z0-9 .
    now I just faced with :
    trimmed = dir_title.match(/^(.*[^_])/);

    What should I change here?!

  • Afshin Haghighatnia

    I just changed trimmed = dir_title.replace(/[^Ø¢-ÛŒa-zA-Z0-9]+/g,'-');

    But, no changes!

  • Afshin Haghighatnia

    So, what should I do now?! Any suggestions ?!

  • Look into the source of the edit screen, you'll find the function:

          function rebasename(title) {
              if (!orig_basename) {
                  dir_title = dirify(title.value);
                  dir_title = dir_title.substring(0, 100);
                  trimmed = dir_title.match(/^(.*[^_])/);
                  if (trimmed && trimmed.length) {
                      setElementValue('basename', trimmed[0]);
                  } else {
                      setElementValue('basename', '');
                  }
              }
          }
    

    It is defined in this template: [Your MT directory]/tmpl/cms/edit_entry.tmpl which you can either hack directly (quick but dirty) or change on the fly by writing a plugin (longer but will work seamlessly across MT versions).

    I would encourage you to create a feature request on Six Apart's bug tracker and ask for an option to have Unicode basenames rather than ASCII ones. I'm sure the Japanese would understand the need for them too. ;-)

  • Afshin Haghighatnia

    Of course I don't know anything about Javascript and the method of writing a plugin for movable type. Using some available codes on the net, I could change a Javascript code in my own PHP code.

    But, as I did the same thing to the code in /tmpl/cms/edit_entry.tmpl , nothing happened. If it's possible help on changing the code. It's an urgent need.

    And of course, what is the way to create a feature request on Six Apart's bug tracker? Where should I ask them to do this for me?!

  • Hi Afshin,

    You could create a feature request from:
    http://bugs.movabletype.org/

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Daily Movable Type Consultant

    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/
    ----------------------------------

    Open Melody Demo
    http://www.openmelodydemo.org/

  • Afshin Haghighatnia

    Thank you very much. I'm going to have a request for this issue in Six Apart's bug tracker.

    But is there a way to change the Javascript code for now?! I need it immediately. Any help is really appreciated.

  • You're welcome!

    You could change the JS function in the file that I've indicated you and then upload it to the server, so that the modified one overwrites the default.

    You may also like to further define how you would like to change that. Because if you just want to add something else to the basename you could do that from the Entry archive template, adding the extra string to the archive mapping pattern.

  • Afshin Haghighatnia

    Of course, I want to make it capable of supporting 32 letters from another language which it's possible by adding آ-ی like a-z or A-Z in Javascript. The problem is here that even by removing that function, I mean "function rebasename(title)", and saving it, No changes happen and everything is like before removing it!

  • Afshin,

    I'm looking at MTOS 5.12 edit_entry.tmpl. It looks to me that the dirify function (in the rebasename(title) block) is what you need to replace with your own function:

    dir_title = dirify(title.value);

    That occurs at line 826 in MTOS 5.12.

    I don't think you have to modify or replace the "trimmed" function.

  • OK, that's a 3 month old topic I just replied to. :(

  • spencer williams

    Thanks for sharing this information.. spence @
    payday loans toronto - http://www.redleafloans.ca/payday-loans-toronto.aspx

  • Slip rings rely on elastic overlap principle, and the rolling lap principle selection as a whole, constitute a reliable rotation connectivity system. As long as the slip ring attached to the infinite rotating equipment, it can provide power energy to the rotating body. So that the rotating body while unlimited rotational movement, but also for other sports, or detect the working conditions in the normal rotation state.

  • electrical slip ring is slip ring can transmit power and signal.

  • This is nice information. Thanks for sheering this

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

code.sixapart.com

141 498

Last Topic: Action Stream for LinkedIn by michael webster on Jan 10, 2013

254 907

Last Topic: Auditors in India by dimpi on May 3, 2013

1873 6643

Last Topic: Main Index Template by Richard on May 7, 2013

89 311

Last Topic: Seeking explanation of files and folders by CosmicKnight on Feb 23, 2013

1520 5507

Last Topic: Is there a way to edit the head element on a post-by-post basis? by jmcg8888 on May 7, 2013

743 3152

Last Topic: Installation Problem by Alex L on Apr 2, 2013

90 334

Last Topic: HELP! I need to 301 over 100 urls on my site via htaccess by justin on Feb 22, 2013

193 801

Last Topic: Deleting Revision History by Will Haynes on Mar 16, 2013

28 97

Last Topic: Movable Price by joe22 on Jan 10, 2013

51 222

Last Topic: Phone App by Duane Langshaw on Apr 3, 2013

65 249

Last Topic: Expanding new rich text editor and implementing table function by Takeshi Nick Osanai on Jul 30, 2012