Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

IncludeWithEdit

Summary: Enable editing of included text
Version: 2005-02-07
Prerequisites:
Status: last tested on PmWiki Version 2.2.0.beta45
Maintainer: KAL
Categories: Editing, Includes

Question

How to place a edit-link before or at the end of included text so that an author can directly edit the included text ?

Will look like that:

some text on a wikipage
..................................................................
                                                           [edit]

included text on the wiki-page
..................................................................

To edit the text of the included text the edit-link on the right can be used (e.g. in Mozilla by clicking with the middle-mouse-button to open the included page in a new tab for editing.)

To include a page with edit-link use the new directive (:included PAGENAME:) (or any other markup-name you prefer, just change the code below)

The separation of the included text and the style of the edit-link can be changed by using css.

Solution:

A new markup and css-styles can be defined to display the edit-link.

Add the following code to your config.php or farmconfig.php

  • to get a button as a edit-link before the included text:
  Markup('included','>if',"/\\(:included\\s+(.+?):\\)/e",
         "PRR().'<p class=\\\'included\\\'><span class=\\\'button\\\'>".
         "[[$1?action=edit|[-EDIT-]]]</span></p>'".
         ".IncludeText(\$pagename,'include $1').".
         "'<br/><p class=\\\'included\\\'/>'");
  • to get a button as a edit-link at the end the included text:
  Markup('included','>if',"/\\(:included\\s+(.+?):\\)/e",
         "PRR().'<p class=\\\'included\\\'>".
         "[[$1?action=edit|[-EDIT-]]]</span></p>'".
         ".IncludeText(\$pagename,'include $1').".
         "'<br/><span class=\\\'button\\\'><p class=\\\'included\\\'/>'");

add some css-definitions for the classes ".included" and ".button" to your skin-css (for display and print). Here's a sample css-definition:

screen.css: display a dotted line and an edit-"button" before and a dotted line after the included text

.included { 
  color:gray; 
  border-top:dashed 1px; 
  text-align:right;
}
.button {
  font-family:Arial;
  font-size:80%; 
  font-weight:bold;
  font-style:normal;
  color:#008000;
  white-space:nowrap;

  border:outset 2px #C0C0C0;
  background:#CCFFCC;

  padding-left:5px;
  padding-right:5px;
}

.button a {
  color:#008000;
  text-decoration:none;
}

print.css: don't print this additional stuff

.buttons, .included { 
  display:none;
}

See also:

It worked out well for something I needed on one of my sites. Here's a link with the system implemented: http://www.pathstoknowledge.com/pmwiki/pmwiki.php?n=Perennis.SpiritWiki KeithCampbell

Discussion

  • additional ideas are very welcome !

How about this (it implies changing border-top to border-bottom in the included style):

Markup('included','>if',"/\\(:included\\s+(.+?):\\)/e",
         "PRR().'[+$1+] [[$1?action=edit|[--EDIT--]]]<br>'".
         ".IncludeText(\$pagename,'include $1').".
         "'<p class=\\\'included\\\'>[[$1?action=edit|[--EDIT $1--]]]</p>".
         "<br/>'");

-Radu


Problem with #from anchor

When a page is included with #from#end like:

       (:included somepage#somepart#partend:) 

than the section edit link does not function and the URI looks like this:

       somepage#somepart%23partend?action=edit

(it opens the included page but not the edit version of the page)

-Paddelboot, 04-2006


Contributor

  • KAL 2004-11-27 - first implementation
  • KAL 2005-02-07 - fixed sample implementation link

The code for having the button below the included text didn't quite work correctly. This is how I solved the problem.

Markup('included','>if',"/\\(:included\\s+(.+?):\\)/e",
       "PRR().IncludeText(\$pagename,'include $1').".
       "'<br/><p class=\\\'included\\\'><span class=\\\'button\\\'>".
       "[[$1?action=edit|[-EDIT-]]]</span></p>'");

Bm?


Suggestion

Why don't put together SectionEdit and the idea of direct include to perform sth like this.

In the Src.Page you have sth. like this

 [[#FirstAnchor]]
 !! Heading
 BlaBla

 [[#SecondAnchor]]
 !!Next Heading
 Blabla

If I look at it with (:autosection:) I get sth. like this

Src.Page edit

Heading

Blabla

edit

NextHeading

Blabla

Lets take a look at the links. The first edit points to

 Src.Page?action=edit&s=1&auto=y&from=Src.Page

But if I include, let's say Inc.Page

 (:include Src.Page#FirstAnchor:)

i get sth like this

Inc.Page

edit

Heading

Blabla

Lets take a look at the links. The edit points relatively to

 Inc.Page?action=edit&s=1&auto=y&from=Inc.Page

Wouldn't it be very very nice, to keep that edit links absolute, it would make more sense. But I think this depends to SectionEdit too.

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 11:42 AM