Support » Plugin: Document Gallery » Displaying only names and dates in a table format

  • Resolved zman8

    (@zman8)



    I’m trying to use the organizational features of this plugin (which is great) to essentially streamline a manual process.

    I’d like to have the Title and Date of the documents ONLY displayed in a table-like format that links to the underlying PDF. — see e.g. netchoice.org/library/all-resources/

    Thoughts of the CSS code? Thanks

    • This topic was modified 1 year, 6 months ago by  zman8.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Dan Rossiter

    (@danrossiter)

    Hi zman8,

    Yes, this could definitely be done. Let me throw something together tonight and I’ll get it to you.

    -Dan

    Thanks Dan… looking forward to the CSS

    Plugin Author Dan Rossiter

    (@danrossiter)

    Hi zman8,

    I’m so sorry. I definitely typed a response to you days ago to tell you it was going to take a bit longer since it’s actually a more involved solution than I initially thought, but apparently I didn’t submit what I typed…

    Anyway, I have a solution for you now. As I mentioned above, the solution is a bit more complicated than I initially thought. You’re actually going to need to use a bit of PHP rather than CSS to get the result you’re looking for.

    First, you’ll want to install Code Snippets which is a plugin that allows you to easily add bits of PHP to your WordPress site. Once that’s installed, you’ll add a snippet with the following code:

    function dg_gallery_template($gallery, $use_descriptions) {
         if ( ! $use_descriptions ) {
             $gallery = '<table id="%id%" class="%class%" %data%>%rows%</table>';
         }
         return $gallery;
     }
     add_filter( 'dg_gallery_template', 'dg_gallery_template', 10, 2 );
    
     function dg_row_template($row, $use_descriptions) {
         if ( ! $use_descriptions ) {
             $row = '<tr class="%class%">%icons%</tr>';
         }
         return $row;
     }
     add_filter( 'dg_row_template', 'dg_row_template', 10, 2 );
    
     function dg_icon_template($icon, $use_descriptions, $id) {
         if ( ! $use_descriptions ) {
             $icon = '<td>%date%</td><td><a href="%link%" target="%target%"><span class="title">%title%</title></td>';
         }
         return $icon;
     }
     add_filter( 'dg_icon_template', 'dg_icon_template', 10, 3 );

    Once this is done, your galleries should all be in tabular format. Be sure when you create your galleries you only have 1 column in order to match the output you’re looking for and ensure that descriptions are not enabled.

    -Dan

    Hi Dan
    Just reading your information there
    And want to know where the code to be added to should it be in the function.php in the theme?

    Max

    Plugin Author Dan Rossiter

    (@danrossiter)

    Max,

    Using the code snippets plugin negates the need for a child theme and use of functions.php. If you prefer that route, just don’t install code snippets and the code from above can be dropped into functions.php instead.

    -Dan

    Dear Dan

    Noted with thanks

    Will give a try now

    This totally rocks! puts me well on my way to meeting a need. Just wondering if / how I can put the date after the title instead of before the title (link to the document)?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Displaying only names and dates in a table format’ is closed to new replies.