How to have an option to select a page template

Hi,

I have installed the Wiki plugin but it is not playing nice with the default page template. Is there a way to have an option to select the page template that should be used for Wiki pages?

In this theme it actually inserts itself into the header, page body and footer http://awesomescreenshot.com/002l9jo31

Thanks

  • Philip John

    Hiya!

    That doesn't sound good and actually suggests that your theme is calling the hook used by Q&A multiple time in the same page, which isn't right at all.

    The screenshot you linked to doesn't seem to work - do you have another one please?

    Also try copying your theme's page.php and naming it incsub_wiki.php. That will be a new template file used purely for wiki pages. You can then edit that to customise the wiki pages in your site.

    Phil

  • jphogbin

    Thanks Phil.

    I am using Salutation theme that is available in Themeforest. We have made the changes you suggested and attached is the result.

    Before it was displaying the wiki in the top grey section where the breadcrumbs are, in the area below and in the black area again which is the footer.

    Will a change to any plugin files be required to make the wiki now show in the page, e.g. a reference to incsub_wiki.php?

    Thanks,

    J-P

  • Nerubio

    So I would say that this issue is still unsolved since a solution was not provided clearlyehre so that it would benefit others in the same situation :slight_frown:

    I have tried to create a template page called template-incsub_wiki.php (that is how you do it in Salutation) and add the content of wiki.php to that page. Then I have copied over wiki.php to the Salutation folder and emptied it and instead adding this line: <?php create_page_layout('incsub_wiki', 'incsub_wiki'); // context = Wiki ?>

    I have then created a layout with the key ID : incsub_wiki.

    This makes two things. Wiki.php will be calling a template page page of the name incsub_wiki.php ( with template_ attached to it in the front and using the layout with key ID incsub_wiki.

    Then I fixed the layout with the key ID incsub_wiki to use a default content area with a sidebar and I made a empty header layout attached to this to see if that would help. Still same problem as you have seen in the screen shoots above here in this thread.

    So any idea?

    Before I continue the site is for the time being behind closed doors for the open public so if needed I can give access to it temporarily if you are willing to take a look and see what can be done.

  • Nerubio

    Hi there mate

    hmmmm, since we will not be using any sub wikis we wont have such problems. @andy have been finding out that plugins such as wiki are using a certain add_filter to add its content to a hook called content. Now this creates a problem since modern themes such as Salutation are using the static blocks to inject content into header and footer area as well. Since Wiki is a plugin that uses that add_filter to content it creates the problem as many other plugins doing the same thing does. Basicly it means that it actually injects its content into header, content area and footer are.

    Here is what he said about this problem and under that area comes the function in the plugin he was talking about:

    It seems the problem is not the plugin adding JavaScript from a shortcode, rather dynamically injecting content by appending to the WP “the_content” filter. This is a big problem for modern themes that make use of custom post types to populate a single page with multiple sources of content. This is what Salutation doing with Static Blocks.

    When a plugin injects it’s content this way, it’s preferable for the plugin to include an option to deactivate that feature for custom post types, however even when this is done it typically does not test against the current instance of “the_content” rather the current page. Eventually plugin developers with catch up with this style of design creation as I believe it’s going to be increasingly popular due to the flexability and control it provides over your content and layout.

    I am working on adding a feature to the theme which gives you control to enable/disable any filter on “the_content” for any post type installed. It’s only a concept at this point. I have done a little research and simple testing to ensure it is possible. I’m not sure how long it will be before this is available.

    If you can find out what the filter name used by the plugin I can give you some custom code to prevent it from showing in the unwanted areas. For example, search the plugin code for something like this add_filter('the_content', 'some_plugin_function_name');. We need the value of some_plugin_function_name to write the exception. It may also appear as a filter on the_post, for example: add_filter('the_content', 'some_plugin_function_name');

    Here is the function for the wiki plugin:

    function load_templates() {
      global $wp_query;
    
      if ($wp_query->is_single && $wp_query->query_vars['post_type'] == 'incsub_wiki') {
          //check for custom theme templates
          $wiki_name = get_query_var('incsub_wiki');
          $wiki_id = (int) $wp_query->get_queried_object_id();
          $templates = array();
    
          if ( $wiki_name ) {
        $templates[] = "incsub_wiki-$wiki_name.php";
          }
    
          if ( $wiki_id ) {
        $templates[] = "incsub_wiki-$wiki_id.php";
          }
          $templates[] = "incsub_wiki.php";
    
          if ($this->wiki_template = locate_template($templates)) {
            add_filter('template_include', array(&$this, 'custom_template') );
          } else {
            //otherwise load the page template and use our own theme
            $wp_query->is_single = null;
            $wp_query->is_page = 1;
            add_filter('the_content', array(&$this, 'theme'), 99 );
          }
          $this->is_wiki_page = true;
      }
        }

    The specific line is:

    add_filter('template_include', array(&$this, 'custom_template') );

    Now comes the most important question:

    How to write the exception so that this problem will be solved...

    ANy helps from our dear support guys here please? :smiley:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.