[pmwiki-users] Link to Pmwiki from Wordpress

9 views
Skip to first unread message

Lars Eighner

unread,
Dec 16, 2011, 9:17:20 PM12/16/11
to pmwiki...@pmichaud.com

These are some remarks about putting wiki-like links to a Pmwiki in a
Wordpress blog.

Who is this for:

a. You have to have some skill in the Wordpress theme you use to make this
work. Don't ask me.

b. This assumes both Pmwiki and the Wordpress blog are on the same server
(file system). It also assumes some knowledge of Wordpress themes and php.
In fact, Wordpress does all the heavy lifting, so you don't have to mess
with the Pmwiki at all.

c. Might be instructive if you are a wizard of a different blogging system.

d. Works only on links to pages in wiki.d; not suitable for admin-type
tasks. Will not work with action, attr, etc. string (no
?action=source, etc.)

e. This may not be workable if you use the Wordpress editor-for-dummies, but
if you use the raw html plugin and regularly compose in html this should
work well for you.

Long lines are broken with \ here for mail. \ means skip the new line and
all following white space characters.

What it does:

Changes the title and styling of links to your Pmwiki depending upon whether
the linked page exists. This may (depending on how you style the links)
make links to wiki pages that do not exist not look like links, but the
links will still be functional so someone with edit permissions can still
create the page (possibly after logging in).

What failed:

Attempts to do this with the whole body of finished Wordpress pages have met
with miserable failure. It needs to be done on the level of entry contents.

This does not permit the raised ? in links to non-existent pages since that
cannot be done by html attributes or style.

Further investigation:

How to do something of the sort if Wordpress and Pmwiki are not on the same
file system (different servers).

Steps:

1. Links to the Pmwiki in the Wordpress blog must have a title beginning
with a keyword. The keyword used here is xxxwiki.

example: <a title="xxxwiki link" href="http://mypmwikiurl/Main/foobar/">

The title attribute must come before the href attribute, the attributes must
be double quoted, and anything between the title and the href will be lost.
There must be no spaces in title="<keyword>. Rest of the title will be lost.

I have no idea how to do this with the Wordpress editor-for-dummies, but it
isn't difficult if you use the raw html plugin and compose in html.

2. You must be able to find where the content is inserted in Wordpress pages
where you want wiki-like links to the Pmwiki wiki to work. This will be
(more than likely) index.php, archive.php, single.php and possibly others.
Usually this is done with the Wordpress function the_content(). It must be
within THE LOOP. Something will be substituted for the_content(), but this
must be done after the necessary functions are in place or it will break
Wordpress.

3. add (suitably edited) to functions.php:

(Note: sample links are to an ADULT site. Don't use/follow them.)

a. for href=\"http://xxxwiki.larseighner.com/pmwiki.php/ substitute
the url of your Pmwiki

b. for /home/users/l/yourusername/public_html/xxxwiki/wiki.d/
substitute the PATH to you wiki.d files ON YOUR SERVER. It may not
look much like this at all.

c. $mylink are attributes for the link if the Pmwiki page does not exist
and if it does exist. You can edit the titles and styles as you see fit or
add a class attribute for styling in the appropriate Wordpress style sheet.

d. In the callback function, change xxxwiki to whatever keyword will be the
first thing in the title attribute of links to the Pmwiki

e. Of course change eighner in function definitions and calls to whatever
you use to identify your user functions in Wordpress.

function eighner_acallback($matches)
{

$myurl = $matches[2];
$myfile = str_replace("href=\"http://xxxwiki.larseighner.com/pmwiki.php/", \
"",$myurl);
$myfile = rtrim($myfile,'/"');
$myfile = str_replace("/",".",$myfile);
$myfile ='/home/users/l/larseighner.com-28674/public_html/xxxwiki/wiki.d/'\
. $myfile;

if(!file_exists($myfile)){
$mylink = 'title="A xxxwiki page has not been created yet." rel="nofollow" '.
'style="text-decoration: none; color: #600;" ' . $matches[2];
}else{
$mylink = 'title="Link to xxxwiki page" '.
'style="font-weight: bold; text-decoration: underline; color: #060;" ' . $matches[2];
}

return $mylink;

}


function eighner_test_link($bod)
{


$bod = preg_replace_callback("@(title=\"xxxwiki.*?\").*?(href=\".*?\")@s", \
"eighner_acallback",$bod);


return $bod;
}


4. Suitably edited, substitute this for the_content() IN THE LOOP in the
places identified in step 2 above.

a. change eighner to whatever you used for the function in function.php
b. the text 'Read the rest etc.' is whatever text should appear where
<!--more--> occurs in the Wordpress entry.

<?php echo eighner_test_link(get_the_content('Read the rest of this \
entry &raquo;')); ?>


--
Lars Eighner
http://www.larseighner.com/index.html
8800 N IH35 APT 1191 AUSTIN TX 78753-5266


_______________________________________________
pmwiki-users mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Peter Bowers

unread,
Dec 17, 2011, 3:34:07 AM12/17/11
to Lars Eighner, pmwiki...@pmichaud.com
On Sat, Dec 17, 2011 at 3:17 AM, Lars Eighner <sur...@larseighner.com> wrote:
> These are some remarks about putting wiki-like links to a Pmwiki in a
> Wordpress blog.

Could you explain a little more in detail what problem this solves?
I'm a total beginner in Wordpress (just did the 5-minute install a
couple weeks ago and just now clicked the "edit post" for the 2nd
time) but links seem to be pretty standard...

I created 4 different links as follows::
* in the default editor (selected my text, clicked on the chain link
icon, pasted the standard pmwiki link, clicked Add Link)
* in the default editor (same - just included ?action=edit to make an
admin type of link)
* choosing the HTML editor tab (used the standard <a
href="http://www.qdk.org/pmwiki/index.php?n=GDQCS.GDQCS">link</a>)
* HTML for admin links (used the standard <a
href="http://www.qdk.org/pmwiki/index.php?n=GDQCS.GDQCS?action=edit">link</a>)

All seemed to work just as expected "out of the box"... So obviously
I'm not understanding what the problem is that you were solving...
Can you give me that big picture?

-Peter

Lars Eighner

unread,
Dec 17, 2011, 7:48:53 AM12/17/11
to Peter Bowers, pmwiki...@pmichaud.com
On Sat, 17 Dec 2011, Peter Bowers wrote:

> On Sat, Dec 17, 2011 at 3:17 AM, Lars Eighner <sur...@larseighner.com> wrote:
>> These are some remarks about putting wiki-like links to a Pmwiki in a
>> Wordpress blog.
>
> Could you explain a little more in detail what problem this solves?
> I'm a total beginner in Wordpress (just did the 5-minute install a
> couple weeks ago and just now clicked the "edit post" for the 2nd
> time) but links seem to be pretty standard...

It makes links to your Pmwiki look different when the Pmwiki page does not
exist. Inside Pmwiki, a link to a page that does not exist has the little
raised question mark (out of the box -- you can change it if you wish). So
if read a Pmwiki article and do not want to (or don't have permission to)
create the new page you know (or soon learn) to ignore the links to
non-exitant pages.

But when you create a link to your Pmwiki in your WP blog, WP ordinarily
doesn't know whether the Pmwiki page exists or not. All the links look the
same. This can be frustrating to users. If a user encounters a high
percentage of links to non-existent pages, the user may give up following
the links at all--which will include links to Pmwiki pages that do exist.

For example, you may have a timeline, a glossary, and your references in
your Pmwiki--kinds of things Pmwiki handles better any blog could. As you
blog, you make links to your Pmwiki for every date, unusual term, and
citation in your blog text. Now, you could go create a Pmwiki page for each
of those links as you blog, but that will certainly interrupt the flow of
the blog. Some of your links to Pmwiki will be to pages that exist and some
will be to pages that do not exist. Readers of the blog won't be able to
tell which is which. And when you are ready to create pages for Pmwiki
links, you won't be able to tell which are already done and which need to be
created. So teaching WP to do something different in two different cases is
what I was writing about.

Now there are some wiki-like extensions for WP and some blog like
extensions for Pmwiki. If you are starting from scratch and plan a fairly
simple site, you might look into WP with wiki-like plugins or Pmwiki with
blog-like recipes. If one of those hybrids suits your needs, go for.

However, with two fairly mature pieces of software like WP and PMwiki, it
only to be expected one does a given task better than the other. For
example, the best ad manager for Pmwiki seems to be Adit, and it really
sucks. So I have taught Pmwiki to use a WordPress ad rotate plugin and I
manage all the ads from WordPress. Now I am teaching WordPress to do wiki
links -- and the first step was to teach it to handle links to Pmwiki.


> I created 4 different links as follows::
> * in the default editor (selected my text, clicked on the chain link
> icon, pasted the standard pmwiki link, clicked Add Link)
> * in the default editor (same - just included ?action=edit to make an
> admin type of link)
> * choosing the HTML editor tab (used the standard <a
> href="http://www.qdk.org/pmwiki/index.php?n=GDQCS.GDQCS">link</a>)
> * HTML for admin links (used the standard <a
> href="http://www.qdk.org/pmwiki/index.php?n=GDQCS.GDQCS?action=edit">link</a>)

Don't all of these links in Wordpress look exactly the same whether the
Pmwiki page exists or not? Making the links look different for non-existent
targets is my point (where 'look different' might mean looking exactly like
ordinary text except when the cursor is over the link or might mean being a
different color).

> All seemed to work just as expected "out of the box"... So obviously
> I'm not understanding what the problem is that you were solving...
> Can you give me that big picture?
>
> -Peter
>
>

--

Lars Eighner
http://www.larseighner.com/index.html
8800 N IH35 APT 1191 AUSTIN TX 78753-5266

Peter Bowers

unread,
Dec 17, 2011, 7:53:19 AM12/17/11
to Lars Eighner, pmwiki...@pmichaud.com
On Sat, Dec 17, 2011 at 1:48 PM, Lars Eighner <sur...@larseighner.com> wrote:
>  Making the links look different for non-existent
> targets is my point (where 'look different' might mean looking exactly like
> ordinary text except when the cursor is over the link or might mean being a
> different color).

Ah, that's what I didn't understand. I understand your post better now.

-Peter

tamouse mailing lists

unread,
Mar 26, 2012, 11:59:43 AM3/26/12
to Lars Eighner, pmwiki...@pmichaud.com
On Fri, Dec 16, 2011 at 8:17 PM, Lars Eighner <sur...@larseighner.com> wrote:
>
> These are some remarks about putting wiki-like links to a Pmwiki in a
> Wordpress blog.

Sorry this is rather late in coming...

I'm wondering if this might be better served up as a WP plugin, rather
than editing the various pages directly in the WP install and your
theme? You could include an admin page that will let you configure
things as you'd like.

Take a look at the blackbirdpie plugin
(http://wordpress.org/extend/plugins/twitter-blackbird-pie/) to get an
idea of how something like this might be done. You could set up some
markup that could be included in your WP post to a wiki page, like:

[PmWiki url="http://wiki.example.com/pmwiki/Group/Page"]

Also, rather than embedding the styles in the link HTML, I'd specify a
class and then in your theme you can give the appropriate style info.

Doing it this way will make the functionality you're seeking
independent from the wordpress installation itself, any theming, which
can be a good thing.

Reply all
Reply to author
Forward
0 new messages