IncludeOtherPages-Talk
Links relative to the included page.
I have a page MyGroup/MyPage. Inside this page is a reference to [[MyPg1]] (which resolves to MyGroup/MyPg1 when viewed on MyGroup/MyPage .)
When transcluded into page OtherGroup/SomePage the included link resolves to OtherGroup/MyPg1.
Is there a parameter that can fix this for transcluded content so that is resolves to MyGroup/MyPg1?
(:include Test.IncludeLink:)
{Test.IncludeLink$:Here}
| Here: This is a link to Test.MyPg1: MyPg1 This is a link to Test.MyPg1: MyPg1 |
See example above. Normally [[Page]] in SourceGroup when included should be rewritten to [[SourceGroup/Page]], unless $EnableRelativePageLinks is set to 0, or someone or something modified $QualifyPatterns. --Petko
To enable error checking for every (:include:) do this:
Create a page Site.IncludeError in your wiki (wiki.d), or your in your farm (wikilibs.d) and inside it put something like:
%red%'''ERROR: An include failed!'''%%
Then add this Markup code the your local/config.php or your local/farmconfig.php
#-------------------------------------------------------------------------------
# add error page Site.IncludeError to every include directive
if($action != "imgtpl")
Markup('IncludeError', '_begin', '/(\\(:include )(.*?)(:\\))/', "$1$2 Site.IncludeError$3");
#-------------------------------------------------------------------------------
--gnuzoo
This added ' Site.IncludeError' to every include statement even if it is contained
inside a [@(:include Main.SideBar:)@] preformatted block.
How to not do that inside a preformatted block? --gnuzoo
Try replacing '_begin' with '>[='. Petko
That works! Super Petko to the rescue again! --gnuzoo
> Note: Previous versions of PmWiki allowed whitespace between #from and #to anchors even though it was not designed to. Newer versions do not allow whitespace anymore. To re-enable this "exploited misbehavior" put this into your config.php or farmconfig.php
Markup('includeanchors', '<include', '/(\\(:include.*?#\\w+)\\s+(#\\w+)/', '$1$2');
Labeling this as "exploited misbehavior" makes it sound really bad. Why is this discouraged? What could possibly go wrong? --gnuzoo
No idea, I don't see when this was changed, and I don't remember ever changing it, or writing this. I've removed it. This is not an exploit in the sense of vulnerability. I suspect the "exploited misbehavior" part is when people uncover some functionality that is unintended and undocumented, and start using it in their wikis. This makes it more work for the developers when we need to update the code and to support these people. For best results on the pursuit of happiness, don't use undocumented features, and don't document them if you didn't design them and won't support them :-). --Petko
This message from 2007 is probably related to this section. --Petko
If I include part of a page (section or line/s) where there are anchor-links within the same page (e.g.[[#name|link text]]), obviously they do not work ... is there a possibility to add an option (a sort of basepage extension) in a way that they can be automatically transformed into standard links (e.g. [[{$FullName}#name|link text]])? - Frank February 25, 2019, at 02:47 AM
This can be done with a custom setting of $QualifyPatterns in config.php, for example:
$QualifyPatterns['/(\\[\\[ *)(#[A-Za-z][-.:\\w]* *\\| *.*? *\\]\\])/'] = '$1{$FullName}$2';
Note that if you include several sections, and they contain links from one to another, the included links will point to the original page anchors, even if the anchor is included in the current page. --Petko March 01, 2019, at 10:21 AM
Thanks a lot. A note for those interested, it also works with TextExtract. -- Frank March 01, 2019, at 01:41 PM
Is there any way to include (chapters of) pages which are protected (authuser.php)? Martin
No, there isn't. The easiest and most secure way to achieve this is the other way around: have the public sections in a public page (passwdread=@nopass or @_site_read) and include those into both the protected page, and the public page.
A different approach could be to include a login form if the visitor has no read permissions on the protected page. Here is what I use for a semi-private calendar (Cookbook:Reminder) on a semi-public intranet homepage:
(:if auth read Reminders:)
[[Reminders?action=edit|edit calendar]] | [[{$Name}?action=logout|logout]]
(:reminder Private.Reminders futuredays=14:)
(:else:)
(:input form action={$PageUrl}:)(:input hidden n {$FullName}:)
To see the calendar please log in:\\
(:input text authid size=10 placeholder="Name":) \\
(:input password authpw size=10 placeholder="Password":) (:input submit value="OK":)
(:input end:)
(:if:)
Instead of (:reminder ...:) you could have (:include ...:).
Note that it is strongly recommended to NOT hide sensitive content inside a conditional in an unprotected page. --Petko July 20, 2018, at 12:04 PM
Is I possible to include older versions of a page? For instance, to show only content up to a certain history revision? Michael
No, currently this is not possible. --Petko August 21, 2015, at 12:21 PM
does basepage with with Cookbook:ThumbList?
basepage does not work for images included through the Cookbook:ThumbList recipe, unfortunately. simon July 30, 2015, at 07:13 PM
Is basepage supposed to apply to the source of attachments in the included text as well?
(In my wiki, page links can be adjusted but attachments remain inaccessible from another group even when setting basepage to the original page location.) --Henning October 15, 2010, at 09:45 AM
No, basepage does not appear to work for Attach: simon July 30, 2015, at 07:13 PM
Are there any solutions to specify the amount of words to be included instead of lines?
My favorable solution would be to have something like (:include PageName#anchor words=30:), which would mean: include 30 words after the anchor #anchor. Is there any implementation of this?
Is it possible to include pages, or lines from pages, without turning them into a block?
eg I am looking for something like the PageList wrap parameter
Is it possible to create a default for a variable?
Likewise, it it possible for a parameter reference? The original question was asked in 2009. It's 2022 now and I wonder if something has been added that could answer these needs. --SteP 2022-09-04
Actually, it was possible to create a default for a {$$variable} in config.php like this:
$IncludeOpt = array( 'self'=>'1', 'var_name'=>'default value', );
Then in a wiki page, if the include directive doesn't have a var_name="something", in the text {$$var_name} will become "default value".
Unfortunately, the parameters lines= or paras=, even if set in , will be ignored for the directive (but will be expanded as variables if $IncludeOpt{$$lines} or {$$paras} are in the included page). --Petko
Displaying the link to not existed Page, similar to existing Group, when including.
The question is difficult to explain, please copy this code to WikiSandbox:
Let's make include of page from other Group, with [[PmWiki]] link inside: >>gray<< (:include PmWikiRu/WikiSandbox:) >><< Then this in Local link: [[PmWiki]]
The question is about [[PmWiki]] link to the page, witch does not exists in both Groups. As we see, the link is different on the current page, and inside include. Why? Is it correct behavior?
Finar October 25, 2018, at 09:20 AM
A link [[PmWiki]] without a group in the inner included page is a link to a page in that group, ie [[PmWikiRu/PmWiki]]. If you want to link to [[PmWiki/PmWiki]], either type it, or type [[{*$Group}/PmWiki]] (PmWiki = group of outer including page, PmWiki = group of inner included page). Same for Site.SideBar which is like included page in other groups. --Petko
Is there a way to say e.g. the included page should have only 50% width, in order to place a picture next to it? (Was trying to do something with tables, but didnt work - included page and figure are shown on top of each other and not next to each other...)
Like with other text and pictures, you can use the lfloat or rfloat WikiStyles to place elements one next to another.
%lfloat% https://pmichaud.com/img/misc/pc.jpg %% (:include PmWiki para=3..3:) |
Key PmWiki Features |
>>rfloat frame width=50pct<< https://pmichaud.com/img/misc/pc.jpg >><< (:include PmWiki para=3..3:) |
![]() Key PmWiki Features |
See also Images.
Or use advanced tables, if the included text doesn't contain such tables.
(:table border=0:) (:cellnr width=50%:) (:include PmWiki para=3..3:) (:cell width=50%:) https://pmichaud.com/img/misc/pc.jpg (:tableend:) | ||
|
This is a talk page for improving PmWiki.IncludeOtherPages.