adam.robinson

Custom field default value issue

Vote 0 Votes

Hello,

I'm currently ordering entries based on a custom field so that the user has fine control over the order of the entrys on a listing page. I've set the default value to 999.

The ordering is working as expected for newly created entries, and entries where they've gone in and re-published. The problem is that for all the other entries (the ones created before i added this custom field) they are not getting the default walue of 999. In fact they are not getting any value and as such appear first in the listing.

So my ordering currently looks like
1) entries that dont have the default value 999 (old entries that havent been republished individually)
2) entries with custom field value (in order)
3) new entries that have the default value 999.

I thought that a global 'entries' publish would add the default value 999 to the older entries but it isn't . I dont want to have to go through each old entry and manually save them individually for this default value to be stored.

Any help on this guys?

Reported on Movable Type 4.3

4 Replies

| Add a Reply
  • Hi Adam,

    What don't you check if the entry in context has a value for the custom field and if it doesn't, then set a variable with the value 999 for that entry?

    This could be done using this simple approach:

    1) set a variable whose value is that Custom Field;

    2) if the variable is zero (there is no custom field value), then set it to 999;

    3) order by that variable.

    You may like to know that there is a plugin called Order, which might be friendlier than the custom field trick.

    http://plugins.movabletype.org/order/

    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/

  • adam.robinson

    Does this mean i need to have nested entries tags?


  • adam.robinson

    <mt:Entries sort_by="field:entry_listing_display_order" sort_order="ascend" include_blogs="$blog_id">

    <div class="col-304">
    <$mt:Include module="Entry Summary"$>
    </div>
    </mt:Entries>


    That is a simplified version of what ive got.

  • Hi Adam,

    Looking at your coding above I realize that what you could do is to set a default value for your custom field (999).

    Then you could:

    1) either go inside each and every old article manually and just save the entry so that the custom field value is saved for that entry;

    2) or you could grab the entry IDs of the entries that are not having a value inside that custom (using <mt:If tag="YourCustomFieldTagHere"><mt:Else><mt:EntryID><mt:If>) and then construct the mysql command to inject database entries for that custom field inside the mt_entry_meta table for those entry IDs with that ordering custom field 999 value).

    Kind Regards,
    Mihai Bocsaru

Add a Reply

Forum Groups

1774 6167

Last Topic: Template modules by Zielun on Feb 16, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1434 5088

Last Topic: Maintenance announcement by Nick on Feb 17, 2012

695 2912

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

174 740

Last Topic: Captcha images rendering slowly by ScottM on Feb 12, 2012

190 568

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012