DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:autostartpage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:autostartpage [2018-01-15 09:55] – [Discussion] redge76plugin:autostartpage [2020-04-14 14:51] (current) – fix for php7 error flexjoly
Line 24: Line 24:
 ===== Installation ===== ===== Installation =====
  
-Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually.+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
 ===== Usage ===== ===== Usage =====
Line 91: Line 91:
  
 ===== Discussion ===== ===== Discussion =====
 +
 +**Update for php7** \\
 +Hi, (I hope I do this right) \\
 +The plugin has a minor error with php7 and a pull-request is open for some year now. So I made a fork and committed the  [[https://github.com/rabidaudio/dokuwiki-plugin-autostartpage/pull/2#issue-57976936|proposed change by splitbrain]]. It worked for me. Here you can find [[https://github.com/flexjoly/dokuwiki-plugin-autostartpage|the new fork]]. Greetz,  --- [[user>flexjoly|flexjoly]] //2020-04-14 14:48//
 +
  
 Registers as [[:devel:event:io_namespace_created|IO_NAMESPACE_CREATED]]. Registers as [[:devel:event:io_namespace_created|IO_NAMESPACE_CREATED]].
Line 106: Line 111:
 On "frusterick manners", you have to create 2 new namespaces for this plugin to work. But after that, it's fine On "frusterick manners", you have to create 2 new namespaces for this plugin to work. But after that, it's fine
  --- [[user>redge76|redge76]] //2018-01-15 09:53//  --- [[user>redge76|redge76]] //2018-01-15 09:53//
 +
 +
 +**excellent - very useful plugin**
 +I notice you comment that one of the todo's is the ability to have different start page templates for different places.
 +
 +well - I wanted that too - so made a few minor amendments - code is hopefully self explanatory - happy if you want to include these changes or if others want to do a similar mod - I am just using a local edit of the plugin on my system - works nice! (also removed a couple of &s so that it would work on php 7.1)
 +
 +  .
 +  .
 +  .
 +  .
 +    public function autostartpage_handle(Doku_Event $event, $param) {
 +        global $conf;
 +        global $INFO;
 +        $ns=$event->data[0];       //namespace that has just been created
 +        
 +        $passed_template = $this->getConf('templatefile');   // the template that is set in the configuration
 +        $templatefile = wikiFN($this->getConf('templatefile'), '', false);   //get the filename for the template
 +        
 +        if (substr_count($passed_template, ":") === 0) {        //no namespace specified in configuration so climb the hierarchy        
 +  /*
 +  This if statement checks to see whether the start page template set in the configuration manager includes a ":"
 +  If it does then this is an absolute startpage template to be used for all new namespaces and the logic progresses as per original plugin
 +  If there is no ":" then the stored value is taken to be the startpage template and is sought within the current namespace structure
 +  first the newly created namespace's parent is checked for a template - if found that is used and we break to the next block of code
 +  if the parent doesnt contain a template then the grandparent is checked by moving the current parent to the temp namespace name
 +  and we go round the loop again. Processing continues till we hit the top level folder.
 +  */
 +    $instance = substr_count($ns, ":") ;                 // how many levels of namespace?
 +     $ns_sepchar = ":";
 + $ns_temp = $ns;
 +            
 +            do {
 +             $parent=implode($ns_sepchar, array_splice(preg_split("/".preg_quote($ns_sepchar, "/")."/", $ns_temp), 0, -1));
 +            $parent_template = $parent .":"  .$passed_template;        
 +            $parent_templatefile = wikiFN($parent_template, '', false);   //get the filename for the parent template       
 +            if(@file_exists($parent_templatefile)){
 +            $wikitext=io_readFile($parent_templatefile);
 +            break;
 +        }  else {
 +        $ns_temp = $parent ;
 +        --$instance;
 +        }
 +        }
 +        while ($instance > 0);
 +       
 +        } else { 
 +        if(@file_exists($templatefile)){
 +            $wikitext=io_readFile($templatefile);
 +        }
 + }
 +  /*
 +      NO FURTHER CHANGES AFTER HERE
 +  */
 +        $ns_type=$event->data[1];
 +        if($ns_type === "pages" && $wikitext){
plugin/autostartpage.1516006505.txt.gz · Last modified: 2018-01-15 09:55 by redge76

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki