Forum Replies Created

Viewing 15 posts - 46 through 60 (of 113 total)
  • Author
    Posts
  • in reply to: Autosum field? #1518
    Marcus
    Member

    Sorry about that, I was trying to be too generic trying to catch all id’s. You just want to catch the input ids.

    It should read:

    jQuery(document).ready(function($){
    	calcMe = function () {
    		var total=0;
    		$('input[id^="_post_meta_calcme_"]').each(function (e) {
    			var cur = $(this);
    			total += ($.trim(cur.val())=='')?0:parseInt(cur.val());
    		});
    		$('input[id^="_post_meta_finalcalc_"]').val(total);
    	}
    });
    

    Marcus

    in reply to: Autosum field? #1515
    Marcus
    Member

    Just thought this script might be a little more beneficial as you have access to jquery in wordpress at any time:
    (Keep your onfocus events, only remove your onblurs)

    jQuery(document).ready(function($){
    	calcMe = function () {
    		var total=0;
    		$('#[^="_post_meta_calcme_"]').each(function (e) {
    			var cur = $(this);
    			total += ($.trim(cur.val())=='')?0:parseInt(cur.val());
    		});
    		$('#[^="_post_meta_finalcalc_"]').val(total);
    	}
    });
    

    Then to make this a universal autosum function, just name your fields that you want autosummed, calcme_fieldnamehere (as the each statement, only checks fields that start with calcme) And name your field for the total ‘finalcalc_fieldnamehere’
    This way, you can reuse this concept anywhere, and this should work out of the box.

    I haven’t tested this code, but from what I can see it should work. LOL

    Marcus

    in reply to: Post Relate Select Dropdown #1444
    Marcus
    Member

    Hey Jason, I was going to comment, but I can see from your gist revisions that you fixed most of your problems.

    I haven’t had a chance to copy your gist and try it, but the post_id=0 do you think it may have anything to do with your default setting? I can’t see another issue, but I haven’t installed it yet. Will post again when I have.

    Marcus

    in reply to: Invalid argument supplied for foreach() #1436
    Marcus
    Member

    I’m just guessing but your piklist function is expecting $box and $brown_description to be arrays.
    Yet in your get_post_metas, you are not loading them as arrays but as singles. (adding ‘, true’ to any get_post_meta request makes it a single not an array, default is ‘get_post_meta(id, meta_key, single=false’)

    Just a guess from looking at your code.

    Marcus

    in reply to: Post Relate Select Dropdown #1435
    Marcus
    Member

    Ahh, youre starting to get under the hood Jason.

    This is a great thing.

    Take a look at the parts/fields folder.
    Take the post-relate.php and the select.php and see if you can’t make a new field called post-relate-select.php and make your own brand new field type.

    🙂

    Once you’ve got field creation down, you’ll be amazed at the things you can do with piklist.

    Marcus

    in reply to: Piklist Demo along with Theme #1408
    Marcus
    Member

    Turns out more needed to be fixed, and it conflicts with what I posted here.

    Put the new code on Gist:
    https://gist.github.com/anonymous/9016756

    And commented on the four lines I changed at the bottom of the gist.

    Marcus

    in reply to: Have Widgets changed at all? #1407
    Marcus
    Member

    In the edits I made in order to get piklist working on my windows and wamp installation that I posted here:
    http://piklist.com/support/topic/piklist-demo-along-with-theme/

    Turns out to be wrong, as it doesn’t allow the proper paths to widgets. So widgets don’t show up.
    I made some more changes (actually reduced the amount of code) and posted it on gist:
    https://gist.github.com/anonymous/9016756

    My comments are below the code and I only altered 4 lines.
    Now (so far) every part of piklist works for me, and I can get back to coding. 🙂

    Marcus

    in reply to: Piklist Demo along with Theme #1405
    Marcus
    Member

    FIXED IT!!!!

    The day has come and I’m loving the new piklist. I was just waiting until I had some free time (or rather some extra time) to sit and dwell with the new piklist. And I love it.

    Most importantly I got it working on Windows Jason. (man I hate windows, microshaft kills me)

    includes/class-piklist.php

    Same fix as the first part I suggested Jason:

    
      public static function add_plugin($type, $path)
      {
        self::$paths[$type] = (stristr($path, ':\\') || stristr($path, ':/'))?str_ireplace('/', '\\', $path):$path;  // EDIT MARCUS EBY
        $path = str_replace(chr(92), '/', $path);
    

    But a little below that is the render function and these lines:

    
    foreach (self::$paths as $_display => $_path)
     {
     $_file = (path_is_absolute($view) ? $view : self::$paths[$_display] . $_path_seperator . 'parts' . $_path_seperator . $view) . (strstr($view, '.php') ? '' : '.php');
    

    Just add the following right after:

    
    foreach (self::$paths as $_display => $_path)
     {
     $_file = (path_is_absolute($view) ? $view : self::$paths[$_display] . $_path_seperator . 'parts' . $_path_seperator . $view) . (strstr($view, '.php') ? '' : '.php');
     $_file = (stristr($_file, ':\\') || stristr($_file, ':/'))?str_ireplace('\\', '/', $_file):$_file;  // EDIT MARCUS EBY
    

    If you notice the search and replace is almost identical to the first, except for one small difference. This replaces the ‘\’ with a ‘/’ and the first one replaced the ‘/’ with a ‘\’ (go figure, stupid windows)

    (please don’t add the EDIT MARCUS EBY, I just do that for grep searches. So I know I’ve hacked Kevin’s masterpiece of coding)

    Voila, it shall work in windows. 🙂

    Hope that fills a need for anyone else out there looking for a windows solution.

    Marcus

    in reply to: What's the template element in post-relate? #1370
    Marcus
    Member

    It’s the html structure for laying out a particular type of field.
    If you look in the demo code, there are a couple of instantiations creating a couple of field templates.

    So in practice, if you wanted to have a field layout almost identical to how piklist normally does it, but you want to set the class field higher in the dom, or if you wanted the ID to reflect the class name you set while creating the piklist field, you could copy a piklist template and change it how you wanted.

    Here’s one from the demo:

        $templates['theme_tight'] = '[field_wrapper]
                                       <div id="%1$s" class="%2$s piklist-field-container">
                                         [field_label]
                                         <div class="piklist-field">
                                           [field]
                                           [field_description_wrapper]
                                             <span class="piklist-field-description">[field_description]</span>
                                           [/field_description_wrapper]
                                         </div>
                                       </div>
                                     [/field_wrapper]';
    

    Marcus <– used to be a teacher, its worse than addiction. 🙂

    in reply to: Piklist Demo along with Theme #1358
    Marcus
    Member

    Sorry Jason, my fix was for 0.8 not 0.9
    I figured you must be having the same problem I did, as you have a very similar setup and thats how I fixed mine.

    I still believe it comes back the $_theme variable as I can see you’ve got mixed / and \ in your paths.
    Which is what is stopping you from piklist seeing valid theme paths.
    When I rip 0.9.1 apart (its been a long week) I’ll look at that specific issue and see if I can fix it.

    If you get to it before I do, then please post your results. 🙂

    Thanks Jason.

    Marcus

    in reply to: Piklist Demo along with Theme #1353
    Marcus
    Member

    Jason, try a couple of these things, as I’ve got a local WAMP development and I got mine working.

    Make sure of your pathing first of all.
    Put piklist as a plugin in the plugins directory, and activate it.
    Any meta boxes go in your theme directory, under piklist/parts/meta-boxes

    In the piklist file includes/class-piklist.php find the lines that say:

    if (isset(self::$paths['theme']))
     {
     if (file_exists(self::$paths['theme'] . $_part))
       {
       $_file = self::$paths['theme'] . $_part;
       }
     }
    

    And replace them with this:

    if (isset(self::$paths['theme']))
     {
     if (stristr($_part, ':\\') || stristr($_part, ':/') || stristr(self::$paths['theme'], ':\\') || stristr(self::$paths['theme'], ':/')) 
       {
       $together = (stristr($_part, ':\\') || stristr($_part, ':/') )?$_part:str_replace('/piklist','',self::$paths['theme']).'/' . $_part;
       } else {
       $together = self::$paths['theme'].$_part;
       }
     if (file_exists($together))
       {
       $_file = $together;
       }
    }
    

    Try that and see if you solve it.

    Marcus

    in reply to: Piklist Demo along with Theme #1339
    Marcus
    Member

    Jason, it probably has to do with the fact your on a windows machine like me.

    Try this if you’re willing.
    In class-piklist.php file in the includes directory of piklist, edit line 144 which is part of the add_plugin function:

    Change this line:

        self::$paths[$type] = $path;
    

    To this:

        self::$paths[$type] = (stristr($path, ':\\') || stristr($path, ':/'))?str_ireplace('/', '\\', $path):$path;
    

    And see if that takes care of it.
    I haven’t played around with 0.90 just yet, as I tend to devote a lot of time to it each time a new release comes out, but I do remember this error from an old piklist install.

    I hope this works for you.

    Marcus

    in reply to: Add More field fails to focus when clicked #1313
    Marcus
    Member

    HI Preston, try this link:

    http://piklist.com/support/topic/add_more-field-focus-bug-firefox-25-0-1/

    Or this link:

    http://piklist.com/support/topic/bug-add_more-not-working-in-settings/

    Solution is commenting out a deprecated command in jquery.

    Marcus

    in reply to: Widget addon #1306
    Marcus
    Member

    Ok, left out a couple of things and made a couple of mistakes, so I thought I would fix it, in case anyone needs to use this in the future.

    First in the parts/shared/widget-select.php file, you need to change the foreach loop from this:

    <?php foreach ($widgets as $w): 
    ?>
    
      <div class="hide-all <?php echo !empty($w['form_data']['width']) ? 'piklist-widget-width-' . $w['form_data']['width'] : ''; ?> <?php echo !empty($w['form_data']['height']) ? 'piklist-widget-height-' . $w['form_data']['height'] : ''; ?> <?php echo $class_name; ?>-form <?php echo $class_name; ?>-form-<?php echo $w['add_on'] . '--' . $w['name']; ?> <?php echo current(maybe_unserialize($instance[$widget_name])) == $widget_name . '--' . $w['add_on'] . '--' . $w['name'] ? $class_name . '-form-selected' : ''; ?> ">
        
        <?php do_action('admin_notices'); ?>
        
        <?php if (!empty($w['data']['description'])): ?>
      
          <p>
            <em><?php echo $w['data']['description']; ?></em>
          </p>
      
        <?php endif; ?>
    
        <?php if ($w['form']) piklist($w['form']; ?>
    
      </div>
    
    <?php endforeach; ?>
    

    to this:

    <?php foreach ($widgets as $w): 
    ?>
    
      <div class="hide-all <?php echo !empty($w['form_data']['width']) ? 'piklist-widget-width-' . $w['form_data']['width'] : ''; ?> <?php echo !empty($w['form_data']['height']) ? 'piklist-widget-height-' . $w['form_data']['height'] : ''; ?> <?php echo $class_name; ?>-form <?php echo $class_name; ?>-form-<?php echo $w['add_on'] . '--' . $w['name']; ?> <?php echo current(maybe_unserialize($instance[$widget_name])) == $widget_name . '--' . $w['add_on'] . '--' . $w['name'] ? $class_name . '-form-selected' : ''; ?> ">
        
        <?php do_action('admin_notices'); ?>
        
        <?php if (!empty($w['data']['description'])): ?>
      
          <p>
            <em><?php echo $w['data']['description']; ?></em>
          </p>
      
        <?php endif; ?>
    
        <?php if ($w['form']) piklist($w['form'],array('sidebarid'=>$sidebarid)); ?>
    
      </div>
    
    <?php endforeach; ?>
    

    All I changed was added an argument onto this piklist call:

        <?php if ($w['form']) piklist($w['form'],array('sidebarid'=>$sidebarid)); ?>
    

    This way it passes the sidebarid var to the final widget form.

    The other change was in the includes/class-piklist-universal-widget.php :
    In the form function change this:

        piklist::render('shared/widget-select', array(
          'instance' => $instance
          ,'widgets' => $this->widgets
          ,'name' => $this->widget_core_name
          ,'widget_name' => $this->widget_name
          ,'class_name' => piklist::dashes($this->widget_core_name)
        ));
    

    to this:

        global $wp_registered_widgets, $wp_registered_sidebars;
        $sidebars_widgets = get_option('sidebars_widgets');
        foreach($sidebars_widgets AS $k=>$v) {
          if ($v[0]==$this->id) {
            $sidebarid=$k;
            break;
          }
        }    
        piklist::render('shared/widget-select', array(
          'instance' => $instance
          ,'sidebarid'=> $sidebarid
          ,'widgets' => $this->widgets
          ,'name' => $this->widget_core_name
          ,'widget_name' => $this->widget_name
          ,'class_name' => piklist::dashes($this->widget_core_name)
        ));
    

    All I did was add this before the render:

        global $wp_registered_widgets, $wp_registered_sidebars;
        $sidebars_widgets = get_option('sidebars_widgets');
        foreach($sidebars_widgets AS $k=>$v) {
          if ($v[0]==$this->id) {
            $sidebarid=$k;
            break;
          }
        }
    

    Which just gets the PROPER sidebar id.

    And added the ‘sidebarid’ argument to the render field.

    Little more work, but its working great.

    Now I have a toggle (via piklist meta box) in any page or post, which when turned on, turns the current page into a sidebar.

    Then in the widget form, it pulls the proper page from the sidebar id or description (testing both) and voila, I can load the necessary information for the widget form for that page/post in the form.

    Completely dynamic widgets and sidebars on a per page/post basis.

    Couldn’t have done it without you piklist.

    Marcus

    in reply to: Interesting bug… Groups that show value on_post_status #1296
    Marcus
    Member

    Fixed it!!!! 🙂

    It was in includes/class-piklist-form.php
    in the save function of the Piklist_Form class.

    I changed this code:

    
              foreach ($data as $key => $value) 
              {
                delete_metadata($meta_type, $id, $key);
    
                if (is_array($value))
                {                  
                  if (!piklist::is_flat($value) && !isset($value[0]))
                  {
                    add_metadata($meta_type, $id, $key, $value);
                  }
                  else
                  {
                    foreach ($value as $meta)
                    {
                      if (!empty($meta))
                      {
                        if (is_array($meta) && count($meta) == 1)
                        {
                          $meta = current($meta);
                        }
                        
                        add_metadata($meta_type, $id, $key, $meta);
                      }
                    }
                  }
                }
              }
    

    To this:

    
              foreach ($data as $key => $value) 
              {
                $orig = get_metadata($meta_type, $id, $key);
                delete_metadata($meta_type, $id, $key);
    
                if (is_array($value))
                {                  
                  if (!piklist::is_flat($value) && !isset($value[0]))
                  {
                    foreach($orig[0] AS $k1=>$v1) {
                      if (!array_key_exists($k1, $value)) {
                        $value[$k1]=$v1;
                      }
                    }
                    add_metadata($meta_type, $id, $key, $value);
                  }
                  else
                  {
                    foreach ($value as $meta)
                    {
                      if (!empty($meta))
                      {
                        if (is_array($meta) && count($meta) == 1)
                        {
                          $meta = current($meta);
                        }
                        
                        add_metadata($meta_type, $id, $key, $meta);
                      }
                    }
                  }
                }
              }
    

    All I did was before it deletes the meta data, I stored it in:

    
                $orig = get_metadata($meta_type, $id, $key);
    

    And then added a quick check (since the surrounding if, knows its an array and not a numeric array):

    
                    foreach($orig[0] AS $k1=>$v1) {
                      if (!array_key_exists($k1, $value)) {
                        $value[$k1]=$v1;
                      }
                    }
    

    It literally builds the missing pieces of the $value array before it adds the meta field, preserving the previous sections. Now I can have multiple groups with some having an on_post_status, and some not.

    Whoohoo.

    Thanks for making something so great guys.

    Marcus

Viewing 15 posts - 46 through 60 (of 113 total)