Use the sections parameter of "include macro"

Hello,

I would like to include a section page within a page using the “Include Macro” but I can’t retrieve the section from my other page.

How can I do this? I tried “#H4” “H4” “name of my section”.

{{include page="Page1/Page2" section="HMySection"/}}

Best regards,

The value of the section is the anchor used to jump to this section in the other page, check the value of the “id” field in that section heading.

The “anchor” is the end of the link when I click on my title in the table of contents? Because if it’s this one it doesn’t work, here’s an example:

{{velocity}}
{{include page="Operations/Page 1" section="#H4.Title4" /}}
{{/velocity}}

What is wrong ?

Are you sure this is the heading id you have ? It has a very weird form since the id is usually built with the title and I find surprising that you have “H4” in your title.

Here is the exact link I have for my title and it does have H4 in it:
https://wiki/bin/view/Operations/Rapprochement%20Bancaire/#H4.SpE9cificitE9sparenseigne

I may be mistaken in retrieving this.
How do you get the ID ?

For this link the code should looks like:

{{include page="Operations/Rapprochement Bancaire" section="H4.SpE9cificitE9sparenseigne" /}}

# is a URL syntax to indicate where the anchor starts, it’s not part of the anchor.

What can we improve on https://extensions.xwiki.org/xwiki/bin/view/Extension/Include%20Macro#HParametersdefinition to make it better? Thx

@tmortagne thank you, I just realized my mistake which was writed in the documentation.

@vmassol The only thing that could be improved would be how to retrieve the anchor:

  • We need an automatic summary
  • Retrieve the link to go to the desired section
  • Parse this link and retrieve only the end without the alphanumeric characters (as indicated in the documentation)

I must be out of context because I don’t understand what you mean here :slight_smile: Are you talking about documentation or something else?

Yes, I thought you were asking me what could be improved about the documentation.
Are you talking about the plugin?

Nope. it’s called a macro BTW :slight_smile:

I was asking about the doc but I don’t understand your answer.

For example:

What does this mean? How would you modify the doc related to this point?

Same question for the 2 other points

Thanks

I’ll try to be more understanding. So I was telling you about what could be improved in the documentation.
The documentation explains which parameter is used, but it doesn’t explain how to retrieve the “anchor”. It was this parameter that was blocking me to used the “include” macro.


To get the “anchor”, it will first be necessary to have an automatic summary that can be generated with this:

{{toc/}}

Without this summary I don’t know how to retrieve the following information:

section="H4.SpE9cificitE9sparenseigne"

Once we have the link to go to the desired section on our page, we have to cut it out to get the end of the link:

#H4.SpE9cificitE9sparenseigne

The “#” character must be removed, and also remove the non-alphanumeric characters if necessary.

H4.SpE9cificitE9sparenseigne

So I was explaining how I was able to retrieve the information from the “hanchor”.

You’re asking me how to modify the documentation to make it better. I think a new page is needed with an explanation of how to retrieve the “anchor” of a page.

I hope I was a little clearer in my explanations?

Thanks! It’s clear now.

I’ve updated the doc at https://extensions.xwiki.org/xwiki/bin/view/Extension/Include%20Macro?editor=inline#HParametersdefinition Let me know if it’s better now!

Thanks

1 Like