NextGEN Gallery
Error loading MVC templates (4 posts)

  1. Bakke
    Posted 2 years ago #


    giving WordPress its own directory will break this plugin.

    I have my content directory set to /content, while WordPress i located in /wordpress. This will give errors in admin like:

    /wordpress/content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_addgallery_page/templates/upload_images.php is not a valid MVC template

    This is because the plugin is using ABSPATH to locate template files, instead of plugin_dir_path() (ABSPATH is for loading WordPress files). The method find_template_abspath() in Mixin_Mvc_View_Instance_Methods, will not be able to locate template files, because $_document_root is wrong!

    The use of ABSPATH to locate plugin files should be completely removed.


  2. photocrati
    Plugin Author

    Posted 2 years ago #

    @Bakke - Have you tried our latest beta version? See this page for more details: http://www.nextgen-gallery.com/nextgen-gallery-latest-beta/

    - Cais.

  3. Bakke
    Posted 2 years ago #

    Yes, I have tried 2.0.55, as well as the "stable" 2.0.40.

    giving WordPress its own directory is not supported at all. This is due to wrong use of the ABSPATH constant (this is used to determine the document root in the plugin, while it actually gives you the location of WordPress, which is not always document root).

    My WordPress-installation is setup like this:
    /path/to/page/wordpress/ - Standard WordPress-installation. No themes or plugins live here.
    /path/to/site/content/ - This is where i keep my themes, plugins and uploads.
    Just as described here.

    NextGen Gallery will go looking for files inside /path/to/page/wordpress/ - because it uses ABSPATH. While it should be looking inside /path/to/site/content/.

    Instead of using ABSPATH as a base for finding files, you should be using constants like WP_CONTENT_DIR, WP_PLUGINS_DIR and functions like plugin_dir_path(). That is the correct way, and would solve this problem.

    Giving WordPress its own directory is becoming more and more popular, and is considered a best practice by many. Supporting this should be a priority.

  4. sebastien.barre
    Posted 2 years ago #

    Same here, my WordPress has its own dir, I'm getting the same errors.
    Did you find a workaround?

    More specifically, my install is:


    where wp-testing/wp-config.php starts with:

    define('WP_HOME',    'http://' . $_SERVER['SERVER_NAME']);
    define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');
    define('WP_CONTENT_DIR', realpath($_SERVER['DOCUMENT_ROOT'] . '/wp-content'));
    define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content');

    Editing nextgen-gallery/products/photocrati_nextgen/modules/fs/class.fs.php fixes the MVC error:

    class C_Fs extends C_Component {
    	function initialize()
    		$this->_document_root = $this->set_document_root(WP_CONTENT_DIR);

    but the path to all internal NextGen CSS/JS files is still incorrect, so there must be another location in NextGen where the plugin path is not computed from the WordPress constants. Actually it seems that ABSPATH is used in many many files, so this is going to be tricky :(

Topic Closed

This topic has been closed to new replies.

About this Plugin

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

About this Topic


No tags yet.