WordPress.org

Forums

File Gallery
[resolved] New templates not recognized and settings ignored (26 posts)

  1. charger15
    Member
    Posted 3 years ago #

    Hi,

    I'm having problems getting my custom file gallery template to work. I duplicated the default template folder and renamed it to cycle. I then put the following code inside a post:
    [gallery include="215,212,213" template="cycle" size="full" link="none" columns="0"]

    If I then look up the source code on the page, I can see that the css file is in there with the correct link to the template folder:
    wp-content/plugins/file-gallery/templates/cycle/gallery.css?ver=1.6.5.6

    However, it does not pick the corresponding gallery.php but uses the one from the default template. It also wont put the correct class to the starttag: <div id="gallery-1" class="gallery default">

    In addition, the name of the new template does not show up in the template dropdown. I tried to deactivate/activate it (with and without use of "Delete all options on deactivation?"), but had no luck so far. I also noticed that if e.g. I use the code [gallery include="215,212,213"] it won't use the settings (for size, link, columns) I've made on the settings page but the default ones. So I always have to write all the options in the shortcode to get the desired result.

    Any idea what's wrong here?
    Thanks!

    http://wordpress.org/extend/plugins/file-gallery/

  2. lukehm
    Member
    Posted 3 years ago #

    Having a similar issue.
    Have you resolved?
    L

  3. charger15
    Member
    Posted 3 years ago #

    No, not yet. I first thought it might interfere with another plugin. But after deactivating every other plugin, the problem was still there.

  4. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @charger15, @lukehm:

    1.) those "default" File Gallery options on the Media Settings page are used to set defaults for File Gallery metabox on post editing screen only.

    They do not have any impact on visual display of your galleries. Anything you set there as "default" value will be shown as the default value for an option in the File Gallery metabox.

    In RC12, I've finally added a notice to the Media Settings page, because this issue has already confused way too many people :D

    2.) Regarding custom templates:

    I can't tell you exactly when I've changed this, but any custom template placed in the plugin folder will be ignored. Please place your custom templates in your theme's directory, in a subdirectory called "file-gallery-templates" (you can filter this location using two filters: "file_gallery_templates_folder_url" and "file_gallery_templates_folder_abspath").

    Also, I've been 'moving things around' in the code, and I've forgot to add a value to one of the constant-turned-variable's (so no custom template worked in RC11), but I've fixed it in RC12 and will release it shortly.

    Thank you for your patience and your bug reports! :)

  5. lukehm
    Member
    Posted 3 years ago #

    Thanks for that.
    Will wait for RC12
    I like the idea of the templates being in the theme folder. Much easier for updates.
    One other question. In a template I wanted to add the attachmentID to a class/id does one of the varibles contain the id?
    Thanks in Advance

  6. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @lukehm: you can use the variable $attachment in your templates, it's an post object that contains current attachment's data.

    So, to get the ID, just use $attachment->ID.

  7. lukehm
    Member
    Posted 3 years ago #

    Great
    L

  8. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    RC12 is out, please test your custom templates against it. Thanks! :)

    You can download File Gallery 1.7-RC12 from here: http://downloads.wordpress.org/plugin/file-gallery.1.7-RC12.zip.

  9. lukehm
    Member
    Posted 3 years ago #

    php file being picked up in theme folder great thanks you
    no stylesheets appear to load not even columns.css
    I'm using file_gallery_shortcode in the template if thats important
    L

  10. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    Yes, if you're calling file_gallery_shortcode() from within your templates, then you must enqueue CSS files manually.

    [gallery] shortcode is parsed before WordPress gets to your theme, so CSS files can be enqueued automatically and show up in document header.

    But when you use file_gallery_shortcode(), document header is already processed, and CSS files cannot be linked from within document body.

  11. lukehm
    Member
    Posted 3 years ago #

    Makes sense
    Will enqueue or add relvant styles to my style.css
    Many thanks again
    L

  12. lukehm
    Member
    Posted 3 years ago #

    Last question I think
    If I select the featured image using FG is it possible to exclude this from the gallery.
    Maybe tag it and exclude that tag.
    I suppoose I could get the featured image id in the FG template and add a variable. Would that be $exclude?
    Best
    L

  13. lukehm
    Member
    Posted 3 years ago #

    Still working on the custom templates

    This time using the [gallery] shortcode in a post
    If I use one of your templates, both gallery.css and columns.css are enqueued
    If still using the gallery shortcode I use a custom template, only the custom gallery.css is enqueued not the standard columns.css.
    Do I need to add this file to my file-gallery-templates folder?

    On another issue exclude does not appear to be functioning, either using [gallery] in a post or file_gallery_shortcode. It does work however if I disable FG handling of [gallery] shortcode.

    I hope this is helpful. I love the plugin
    Best
    L

  14. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    That's by design - "columns.css" is included only if you're using one of the default templates.
    As it's a small file, best if you just copy its contents into your template's CSS.

    Regarding exclude: thanks for catching that - I recently switched all attachment queries to use WP_Query class directly, as opposed via get_posts(), and forgot to change 'exclude' parameter to 'post__not_in'.

    I'll release RC13 tomorrow, thanks again :)

  15. lukehm
    Member
    Posted 3 years ago #

    Thank YOU (:i
    Slightly off piste
    What does a cevapcici and a beer cost these days in Zagreb - or do you prefer coffee?

  16. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @lukehm: shouldn't be more than 5-6 euros :)

    And I actually do prefer coffee these days :D

  17. lukehm
    Member
    Posted 3 years ago #

    Just a polite enquiry on how RC13 and the exclude bit was coming along.
    Many Thanks
    L

  18. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

  19. lukehm
    Member
    Posted 3 years ago #

    Great :) - No panic

  20. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    File Gallery v1.7-RC13 is out, please download it from here: http://wordpress.org/extend/plugins/file-gallery/download/.

    I hope everything works alright :)

    I've made slight changes in the interface - please comment if it's better or worse than before ;)

  21. Aldi
    Member
    Posted 3 years ago #

    Help! My custom template is also not recognized and I can't figure out why.

    Running v1.7-RC13, I'm using the file_gallery_shortcode function and filter_fg_default_url filter. But it is not being detected.

    Here's the code in my funtion.php:

    function filter_fg_default_url( $url ){
    	$url = get_bloginfo("stylesheet_directory") . "/file-gallery-templates/default";
    	return $url;
    }
    add_filter('file_gallery_default_template_url', 'filter_fg_default_url');

    And in my single.php:

    $file_gallery = file_gallery_shortcode(
    	array(
    		'order' => 'ASC',
    		'orderby' => 'file gallery',
    		'id' => $post->ID,
    		'columns' => 1,
    		'size' => 'thumbnail',
    		'link' => 'attachment',
    		'include' => '',
    		'exclude' => '',
    
    		'template' => 'default',
    		'linkclass' => '',
    		'imageclass' => '',
    		'rel' => 1,
    		'tags' => '',
    		'tags_from' => 'current',
    		'output_type' => 'html',
    		'output_params' => 1,
    		'attachment_ids' => '',
    		'mimetype' => '',
    		'limit' => -1,
    	)
    );
  22. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @bedex78: when using the shortcode function in your template, the CSS files aren't enqueued automatically.

    See a few posts up for an explanation: #post-2468651

  23. Aldi
    Member
    Posted 3 years ago #

    The CSS is not really a problem as I'm using my style.css to style the gallery. The problem is that my custom template is just not being implemented. It kept displaying the default template from the plugin folder, instead of the one I created in a folder in my theme. Any idea?

  24. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @bedex78: you also need to override the path to your template using the 'file_gallery_default_template_abspath' filter.

    Filtering the 'file_gallery_default_template_url' is for the CSS files, 'file_gallery_default_template_abspath' is for the PHP files, as they need to be read by File Gallery.

  25. Aldi
    Member
    Posted 3 years ago #

    Thanks for the quick reply!

    Anyway, I did try that but still didn't work. I end up using file_gallery_templates_folder_abspath instead.

    Cheers!

  26. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @bedex78: thanks for the info. There was a cut/paste mishap which I've fixed in RC14 - I've tested it and it works fine now :)

    Download File Gallery v1.7-RC14 from here: http://wordpress.org/extend/plugins/file-gallery/download/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • File Gallery
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic