Support » Plugin: Attachments » Installation and default instance

  • Resolved enseikou

    (@enseikou)


    Hello all!
    I’m an amateur sysad working for a nonprofit, just getting started with PHP. I’m trying to use this plugin but I’m clueless, because the documentation is incomplete and gibberish to me.
    Apparently, to install it I must “Implement Attachments in your theme’s functions.php or your own plugin (see Usage)”.
    However, the linked page gives no clue on how to “implement” that. It tells you how to disable the default instance or customize it, but not how to tell whether the default instance has been created automatically or, if not, what piece of code you have to add to the file functions.php, nor where.
    On the other hand, the instructions on how to modify theme templates, which are the last step, are quite complete, but seem insufficient to do the trick. Now my posts only display this:

    stdClass Object
    (
        [id] => 1308
        [fields] => stdClass Object
            (
                [title] => ke0301.pdf
                [caption] => 
            )
    
        [post_id] => 125
    )

    Please give me some hint, and complete the documentation.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter enseikou

    (@enseikou)

    Nevermind, I found out I actually needed to edit the HTML code myself in the template single.php to make a clickable thumbnail. This one worked quite well:

    ?>
    <?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
    <?php if( $attachments->exist() ) : ?>
      <h3>Attachments</h3>
      <p>Total Attachments: <?php echo $attachments->total(); ?></p>
      <ul>
        <?php while( $attachments->get() ) : ?>
          <li>
            <a href="<?php echo $attachments->url(); ?>" title="<?php echo $attachments->id(); ?>: <?php echo $attachments->field( 'title' ); ?>, <?php echo $attachments->filesize(); ?>" type="<?php echo $attachments->type(); ?>/<?php echo $attachments->subtype(); ?>"><img src="<?php echo $attachments->src( 'full' ); ?>" alt="<?php echo $attachments->field( 'caption' ); ?>"></a>
          </li>
        <?php endwhile; ?>
      </ul>
    <?php endif; ?> 
    <?php

    You should make your documentation a bit more clear! And with more examples!

    • This reply was modified 2 years, 10 months ago by enseikou.
Viewing 1 replies (of 1 total)
  • The topic ‘Installation and default instance’ is closed to new replies.