Viewing 3 reply threads
  • Author
    Posts
    • #7873
      oferli
      Participant

      After few weeks that the back-end was working fine tonight, while the user edit the page back-end and save, all the data beside the 1’st element had been disappear. Sure enough the data are fine in the front-end

      this is my meta-box file

      <?php
      /*
      Title: Sections
      Post Type: page
      Template: catalog
      priority: high
      order: 20
      */

      function pl_color() {
      global $lo_options;

      $colors = maybe_unserialize($lo_options[‘colors’]);
      $ret[‘none’] = ‘Choose Color’;
      foreach ($colors as $color) {
      $ret[$color[‘name’]] = $color[‘name’];
      }
      return $ret;
      }

      function pl_products () {
      $posts = get_posts(array(
      ‘order’ => ‘ASC’,
      ‘orderby’ => ‘title’,
      ‘meta_key’ => ‘product ID’,
      ‘post_type’ => ‘page’,
      ‘post_status’ => ‘publish’,
      ‘posts_per_page’ => -1,
      ‘meta_query’ => array(
      ‘relation’ => ‘OR’,
      array(‘key’ => ‘product ID’, ‘compare’ => ‘EXISTS’, ),
      array(‘key’ => ‘img_dir’, ‘compare’ => ‘EXISTS’, )
      )));
      $ret[‘none’] = ‘Choose product’;
      foreach ($posts as $p) {
      $ret[$p->ID] = $p->post_title;
      }
      return $ret;
      }

      $products = pl_products();
      $color = pl_color ();

      piklist(‘field’, array(
      ‘type’ => ‘group’
      ,’field’ => ‘section’
      ,’label’ => ‘Section’
      ,’add_more’ => true
      ,’fields’ => array(
      array(
      ‘type’ => ‘text’
      ,’field’ => ‘name’
      ,’label’ => ‘Section title’
      ,’columns’ => 6
      )
      ,array(
      ‘type’ => ‘textarea’
      ,’field’ => ‘mobile’
      ,’label’ => ‘Mobile description’
      ,’columns’ => 6
      )
      ,array(
      ‘type’ => ‘group’
      ,’label’ => ‘Product’
      ,’field’ => ‘products’
      ,’template’ => ‘field’
      ,’add_more’ => true
      ,’conditions’ => array(
      array(
      ‘field’ => ‘action’
      ,’value’ => ‘list’
      )
      )

      ,’fields’ => array(

      array(
      ‘type’ => ‘select’
      ,’field’ => ‘product’
      ,’label’ => ‘Product’
      ,’columns’ => 3
      ,’choices’ => $products
      )
      ,array(
      ‘type’ => ‘select’
      ,’field’ => ‘color’
      ,’label’ => ‘Color’
      ,’columns’ => 3
      ,’choices’ => $color
      )

      )))));

    • #7876
      sturple
      Participant

      So I have had the same problem.
      When you have a group element if you delete one of the elements that is not on the end, it saves it back to the database it uses an associated version of the array and therefore it doesn’t reload. The good news is that in the database you can fix this.
      when the item gets deleted this array uses the associated version and not the indexed version. Hopefully this is making sense.
      Ie
      something like
      [
      0 = > ‘test0’,
      2 = > ‘test2’,
      3 => ‘test3’
      ]
      THE FIX
      Go into your database find the element convert it to array, and replace the 2, and the 3 with a 1, and a 2 respectively or what ever is your database, and then re-serialize it and it should resolve the problem.
      THE TEMP FIX
      Move all elements to be deleted at the bottom first before removing.

      I think this is in some kind of bug list, but not 100% sure, as there has been similar issues, but not exactly the same.
      I hope this helps.
      Regards,
      Shawn

    • #7882
      Steve
      Keymaster
    • #7884
      oferli
      Participant

      Thanks Steve, unfortunately the client already ‘updated’ the original page so all info had been lost.

      I used the info in the link you suggested, hopefully this will do the trick

Viewing 3 reply threads
  • The topic ‘backend is 'broken' while the front is OK’ is closed to new replies.