[pmwiki-users] Sitemapper; how to determine backlinks from PHP?

Eemeli Aro eemeli at gmail.com
Sun Jun 28 14:45:43 CDT 2009


2009/6/26 Adrianna Pinska <adrianna.pinska at gmail.com>:
> Since I think most of my users create new pages by linking to them,
> and the most logical place for the page to go in the sitemap is
> underneath that linking page, I think it would work quite well if
> Sitemapper retrieved a list of backlinks for the new page and picked
> the first one (there should only be one at this point) to be the
> sitemap parent (it could fall back to the top-level group page if
> there is no backlink, perhaps because the page was created in another
> way).
>
> Is it feasible / possible to do this?  The only information I have
> been able to find on backlinks describes how to display backlinks on
> the wiki (with pagelists, etc.).  Is there a function I can use to
> obtain the list of backlinks for the current page, inside a recipe?

Good idea, this. To do it, the part of Sitemapper you'll want to poke
at is the SmAddPage function. The list of backlinks you should be able
to get from the MakePageList function found in scripts/pagelist.php.
I'd guess that the proper value of for $opt in this case is array(
'link' => 'New.PageName' ) and for $retpages 0 or false, but you
should test that.

Keep in mind that this might end up giving you more hierarchical depth
than you might want, as linking from page A to page B and from there
to page C will add two levels.

I managed to come up with Sitemapper early enough for the sites where
I have it in use that I've been able to give as the suggested pattern
for creating new pages just writing the wanted page name in the
location bar, following the Create ... link on the 404 page, and
trusting Sitemapper to make the page visible.

The whole recipe might benefit from yet another rewrite, but TBH I
can't be bothered as it seems to work well enough for my own use and I
haven't heard too much comment on it from elsewhere.

eemeli



More information about the pmwiki-users mailing list