• Resolved karidemi

    (@karidemi)


    First off, let me just say how completely awesome this plugin and its developers are for being so helpful and responsive to requests.

    But, of course, now I have a problem 🙂

    I have successfully used the three new filters to manage the output of the plugin and everything is working as expected, except for the descriptions. They are appearing outside of the HTML I am rendering (a table) and I don’t see a specific tag for rendering them the documentation. Is there a %desc% or something I should be using?

    Thanks again!

    https://ww.wp.xz.cn/plugins/document-gallery/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dan Rossiter

    (@danrossiter)

    Rats! You’re absolutely right. I did not think about that.

    I’ll work on getting a patch out to address that issue either late today or tomorrow.

    Thanks for pointing that out!
    -Dan

    Plugin Author Dan Rossiter

    (@danrossiter)

    Hi karidemi,

    I don’t have time to test this solution this minute, but if you you want to try replacing toString() in inc/class-document.php with the following, I *think* it will give you what you want.

    -Dan

    public function __toString() {
          static $find = null;
          if (is_null($find)) {
             $find = array("%link%", "%img%", "%title_attribute%", "%title%", "%description%");
          }
    
          $thumb = $this->gallery->useFancyThumbs()
              ? DG_Thumber::getThumbnail($this->ID)
              : DG_Thumber::getDefaultThumbnail($this->ID);
    
          $repl = array($this->link, $thumb, $this->title_attribute, $this->title, $this->description);
    
          $doc_icon = apply_filters(
             'dg_icon_template',
             '   <div class="document-icon">' . PHP_EOL .
             '      <a href="%link%"><img src="%img%" title="%title_attribute%" alt="%title_attribute%" /><br>%title%</a>' . PHP_EOL .
             ($this->gallery->useDescriptions() ? "   <p>%description%</p>" . PHP_EOL : '') .
             '   </div>' . PHP_EOL,
             $this->gallery->useDescriptions(),
             $this->ID);
    
          $core = str_replace($find, $repl, $doc_icon);
    
          // users may filter icon here
          return apply_filters('dg_doc_icon', $core, $this->ID, $this->gallery->useDescriptions());
       }
    Thread Starter karidemi

    (@karidemi)

    Worked like a charm. Thanks!

    Thread Starter karidemi

    (@karidemi)

    Ok, one last thing… I hope!

    Now, I am trying to have the galleries with descriptions render differently than those without. To do that I’m passing in an argument to my filter function : dg_gallery_template_func($desc) and then using an if/else to see if $desc is true or not. However, it appears to always return true, regardless of if I actually have descriptions turned on. \

    I did a test and when I return the value of $desc, it returns the whole gallery instead of the bool value, like I would have assumed.

    Am I doing this correctly?

    -Karissa

    Plugin Author Dan Rossiter

    (@danrossiter)

    Glad that tweak for the descriptions worked! I’ll have it in the next official release sometime soon 🙂

    With the filtering function, you’ll want to accept two parameters. The first value will be, as you discovered, the gallery as it is generated (the value being filtered). The second parameter will receive the boolean you are looking for.

    Let me know if that works for you!
    -Dan

    Plugin Author Dan Rossiter

    (@danrossiter)

    Sorry, I lied about 2 parameters. It’s actually 3. The first is the default icon template, the second is the attachment ID, and the third is the boolean value you’re looking for.

    For the other two filters, it is just the 3.

    -Dan

    Thread Starter karidemi

    (@karidemi)

    Thanks, Dan. With your help I was able to get this working to my satisfaction!

    -Karissa

    Plugin Author Dan Rossiter

    (@danrossiter)

    Fantastic! So glad to hear it 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘rogue descriptions’ is closed to new replies.