# Helping Give Away Psychological Science/Standard Operating Procedures/Transclusion

HGAPS is finding new ways to make psychological science conferences more accessible!
Here are examples from APA 2022 and the JCCAP Future Directions Forum. Coming soon... ABCT! ~ More at HGAPS.org ~

## Introduction

This document explains the use of tranclusion as a Wiki skill in the context of HGAPS. For those with backgrounds or knowledge of computer science, transclusion is a function that seeks a specific query, returning all content labeled under that query. In other words, transclusion is a way to automatically copy and paste content from other parts of Wiki using a bit of code. When the source content is updated, all pages that include the appropriate transclusion tags are also updated.
Transclusion consists of two parts: the source page(s) and the destination page(s). The source page is the home of whatever content you want to copy. The destination page is the place you want to paste the source page’s content to. You can have many destination pages using the same bit of code, and you can create code in such a way that you are pulling content from many different source pages.
For example, if we had a source page that described the role of HGAPS, we could transclude this source page to dozens of other HGAPS pages (i.e. our destination pages). Once we update what HGAPS is doing on the source page (maybe we pick up extra projects and the like), all of our dozens of other pages where the transclusion tag has been placed are also updated.
Transclusion essentially provides ways to streamline information dissemination, make it easier to update many pages at once, and create composite pages readily from already crafted material. If used effectively, transclusion can really speed up the rate in which HGAPS pages are created.
Transclusion can only be used through the WikiText editor and requires some higher levels of knowledge on how to edit wiki source code, as it is a pretty technical skill. Those with backgrounds in comp sci should pick this up easily, as many topics from comp sci are analogous to WikiText’s unique language (functions, parameters, arguments, syntax, code grammar, etc.).
Below are some links to get familiar with WikiText to lay a solid foundation for getting a good grasp of transclusion:
* CRITICAL: for a basic intro to everything wiki-editing
* CRITICAL: for an in-depth coverage of wikitext (i.e. source code) editing
It is also beneficial to have some understanding of editing wiki with HTML tags. These tags allow for some great formatting options not easily available in the original wiki editor. It is a useful tool to use for places other than transclusion too! A good resource to use is listed below:
* HIGHLY RECOMMENDED: HTML editing
Lastly, for a more in-depth coverage of what transclusion can do apart from what is listed in this document, please refer to these Wiki pages:
* RECOMMENDED: Wikipedia Transclusion
* OPTIONAL: Wikimedia Transclusion
PLEASE NOTE: The above resources are pulled from Wikipedia. There are instances where Wikipedia code does not directly translate to Wikiversity; however, in the creation of transclusion pages, I have not come across any discrepancies though they may still exist.

## WikiText Syntax and Transclusion

The content located in your source page (and any wiki page) can be called a template. Transclusion takes the page content, aka the template, and pastes it into the destination document. There are a few tricks to narrow down information in the template for transclusion, say if you only wanted to copy and paste a specific section within the source page. The first section will focus on transcluding entire templates and all the syntax that can be used for source pages. Later sections will focus on narrowing down your search to specific headings using unique identifiers for those headings.

### Transcluding Whole Pages

To use content from a source page, you first have to tell wiki that your source page is a template. Much like linking to other wiki pages using double square brackets [[Pagename]], source pages can be turned into templates using double curly brackets {{Pagename}}. Note that if you move a page to a different namespace, your pagename will also change and will need to be updated in your transclusion tag. Once you call the name of the page in double curly brackets, the entire contents of your source page will be copied wherever you put the transclusion tag. Below is a graphic explaining the effects of calling your source page in different sections of wikitext (source page is B and destination pages are A, P and Q). The top row is what the viewer will see while the bottom boxes are what appears in the editor window.

### Transcluding Parts of a Page Through Source Page Syntax - Useful for Specially Created Transclusion Pages

Source
Let’s say you don’t want to transclude an entire page, but rather specific parts of the page. There are two ways of accomplishing this. You can either put special syntax into the source page’s code to direct what is transcluded or you can craft specific transclusion tags that seek out desired information on the source page. The first approach is useful for when you have source pages specifically created to be used in transclusion. The second approach is useful for when you wish to transclude from a page that was not originally designed specifically for transclusion. The first approach using special source page markup is described below, while the second approach is described in greater detail in the following three sections. This first approach requires various HTML tags to be used to designate what content in a source page is up for transclusion. These tags are <noinclude>, <onlyinclude> and <includeonly>. Depending on which tag you use, the source page is transcluded very differently. These tags can be used to include or exclude different content from being transcluded. To use these tags, simply surround the targeted content with the <(desiredtag)> and </(desiredtag)> syntax much like HTML markup. The first two tags are pretty much self-explanatory, but the last tag might be a bit trickier.

#### <noinclude></noinclude>

The noinclude tag will transclude all information on a source page except that which is surrounded by this tag. This effectively lets you write notes on your source page to potential editors which do not get copied onto the destination page.
          Ex: This info before the tag will be transcluded. <noinclude>This content is inside the tag and will not be transcluded.</noinclude> This other info after the tag will be transcluded.

#### <onlyinclude></onlyinclude>

The onlyinclude tag will transclude only the information located within this tag on the source page. In other words, this tag only includes surrounded content in its copy and paste functionality.
          Ex: This info before the tag will not be transcluded. <onlyinclude>This content is inside the tag and will be transcluded.</onlyinclude> This other info after the tag will be not transcluded.

#### <includeonly></includeonly>

This tag does not show content on the source page rendered view but will show content within the source page edit view. This tag will show content on the destination page rendered view. This is the most confusing tag to work with.
          Ex: This info before the tag will be transcluded and rendered on the source page. <includeonly>This content is inside the tag and will be transcluded but will not be rendered on the source page.</includeonly> This other info after the tag will be transcluded and rendered on the source page.
Below is an example of what is transcluded in various instances:
| WikiText | What is rendered on the source page | What is rendered on the destination page |
| <noinclude>text1</noinclude>text2 | text1 text2 | text2 |
| <onlyinclude>text1</onlyinclude>text2 | text1 text2 | text1 |
| <includeonly>text1</includeonly>text2 | text2 | text1 text2 |

#### Parametrization Method: Transcluding Specific Sections Using Multiple Tags

Let’s pretend we decided to create a source page that listed all of HGAPS roles, projects, and responsibilities. We created this page so it would be easy for HGAPS members to transclude their unique involvement in certain projects into the Wikiversity user page. This page would essentially serve as a menu that any HGAPS member would be able to pick from to describe their personal journey with HGAPS as well as adding a sense of uniformity across HGAPS member pages. To do this, we need a way to have multiple sections of the source document have transclusion functionality but also be identifiable. In this way, you can tell wiki to pick and choose certain sections to include in your transclusion. This is accomplished with the parametrization method of transclusion. The parametrization method allows you to give specific names to your tagged sections using the onlyinclude tag. It involves special markup in your source page and a special function call on your destination page.

##### Source Page Markup

Insert the following line into the source page immediately before the first line of each section to be transcluded, substituting SECTIONNAME (twice) with the unique name of the respective section. The section name can be any identifier and must be unique within that document: <onlyinclude>{{#ifeq:{{{transcludesection|SECTIONNAME}}}|SECTIONNAME| End each transcludable section with the code below: }}</onlyincude> In other words, this markup surrounds your transcludable section with the onlyinclude tag as well as gives that section a unique identifier (the {{#ifeq: syntax) which can be called up in your destination page. Going back to the theoretical page that lists all of HGAPS roles as an example, we can see that our source page might look something like the example below. We use Assessment Center as the section for this example:
    <onlyinclude>{{#ifeq:{{{transcludesection|ASSESSMENTMEMBER}}}|ASSESSMENTMEMBER|
    All of your information here. You might put the information of what a group member would do in the Assessment Center Group. All members of that group could use a specific tag (discussed below) to call this section to their user page. This streamlines User page creation processes and makes the entire group look more uniform.
    }}</onlyincude>

##### Destination Page Markup

To transclude a section marked as above into another page (the "destination page"), use the code below on your destination page, substituting PAGENAME for your the "source" document, and SECTIONNAME with the name of the section you previously identified: {{PAGENAME|transcludesection=SECTIONNAME}} Warning: if you do not use the transcludesection markup, you will transclude every section within that page that is surrounded by the <onlyinclude>...</onlyinclude> tags. If you choose to use the parametrization method, be sure you are using the unique identifier on the destination page function call. Continuing from our example of the source page with HGAPS rolls and the Assessment Center group, we can see what an assessment center group member would put on their user page (the destination page) in order to copy over the transcludable section on our source page. Let's say our source page is called HGAPS Member Roles and use our section name from the above section.
    {{HGAPS Member Roles|transcludesection=ASSESSMENTMEMBER}}
Also, when providing PAGENAME, without providing a Namespace, the wiki will assume that the PAGENAME belongs in the Template Namespace. To transclude from a Mainspace article, use :PAGENAME {{:PAGENAME|transcludesection=SECTIONNAME}}

### Transcluding Parts of a Page Using Wiki Section Headers - Useful for Already Established Pages

Source
What if we wanted to grab a section from another of our wiki pages that might not have special tags already in place? Maybe it was created a year before HGAPS started introducing transclusion functionality into our pages. To do this, we are actually able to use special code to browse any wiki page and find a specific header where we can copy and paste that header's content. Use the following bit of code on our destination page: {{trim|{{#section-h:PAGENAME|SECTIONNAME}}}}
* The trim part prevents any extra line spacing from appearing in our transcluded content. This is just an extra precaution to prevent undesired formatting.
* The #section-h part dictates that we are seeking to transclude a specific section that can be found using a particular header search (the -h part of the code).
* The Pagename part tells us which page to look for our section (to denote a section within a subpage, use PAGENAME/SUBPAGE|SECTIONNAME syntax).
* The |SECTIONNAME part is our query of interest, and any content located within that section is transcluded to our destination page.
Transcluding multiple sections from a variety of pages is an easy way to gather a lot of complicated information without reinventing the wheel. This syntax is especially useful because it does not require premade, common transclusion source pages with special markup.
If you wish to transclude only the content before the table of contents (the lead of an article), use the following code:
* {{trim|{{#section-h:PAGENAME}}}}
If you wish to transclude a section located within a subpage of a namespace, use the following code:
* {{trim|{{#section-h:PAGENAME/SUBPAGE|SECTIONNAME}}}}
If you wish to document where you transcluded the information from without having to go into edit view, you can use the following special function: {{Translcuded section}}
* This function inserts a special note before the transcluded section with a link to the source page.
* Code for noting where a whole section comes from:
** {{transcluded section|source=PAGENAME}}
*** Renders as: This section is transcluded from PAGENAME.
* Code for noting where a part of a section comes from:
** {{transcluded section|source=PAGENAME|part=yes}}
*** Renders as: Part of this section is transcluded from PAGENAME.

### Transcluding Subpages Within Broader Namespaces

Source
To transclude a subpage:
* The general syntax is {{Namespace:Pagename/subpagename}}.
* If it is a subpage you are editing, then the syntax is {{/subpagename}}
* For an encylopedic article it is {{:Pagename/subpagename}}, althought article subpages are normally disabled.
* For a template, it is {{Pagename/subpagename}}.

## Potential Applications for HGAPS
### Creating a Menu of HGAPS Roles for HGAPS Members' User Spaces

Let’s pretend we decided to create a source page that listed all of HGAPs roles, projects, and responsibilities. We created this page so it would be easy for HGAPs members to transclude their unique involvement in certain projects into the Wikiversity user page. This page would essentially serve as a menu that any HGAPS member would be able to pick from to describe their personal journey with HGAPS. It would be best to use the parametrization method of transclusion here. This allows us to have a common source page which has multiple transcludable sections. On our user pages, we can use our defined unique indentifier for each role to selectively transclude sections relevant to our particular experiences.

### Creating User Boxes

When two pages need to discuss the same material in the same way, they can share a section. This involves creating a third page and transcluding that page onto both pages. This third page may be a page in its own right or a subpage of either of the other two. In HGAPS, this can be used to create specific User Boxes for certain people. If we have a third page specifically for transclusion, we can list all User Boxes possible in HGAPS. We can then use special transclusion tags to pick and choose which user boxes are appropriate for certain pages. As with our potential HGAPS roles page, this page would best benefit from the parametrization method of transclusion due to the common source page and unique identifiable sections we can create. We could even have our user boxes page and roles page be located in the same article.

### Banner Page

This concept allows us to have an emergency banner located on our wiki pages. This allows us to get information out very quickly in the case of an emergency (pandemic, school shooting, wild fire, hurricane, etc.). This has actually already been implemented to some extent. See our banner page. In its current iteration, it uses the {{trim|{{#section-h:PAGENAME/SUBPAGE|SECTIONNAME}}}} syntax. However, this page would probably best benefit from the <onlyinclude>...</onlyinclude> source document syntax. The current iteration is more complicated than necessary. Planned transition is in the works.

### Readily Creating New Pages from Already Existing Content

Source
Composite pages consist, wholly or partly, of transcluded destination pages. The wikitext of such a page may, partly or fully, consist of tags for the inclusion of various destination pages. The destination pages are usually not in the template namespace, and are often full pages in their own right. Composite pages are intended to gather them into a central location. Viewing a composite page is convenient when there are many small, related destination pages, in that it allows an overview of all the components without the effort of following numerous links. Editing a section of a destination page can be done directly from the composite page, see editing sections of included templates. After saving, one ends up editing the component page to which the section belongs.
For HGAPS, one can easily see how using various parts of different HGAPS pages can be used to create a new, “frankenpage”. For example, let’s say we partnered with the Carolina Center for Autism and Behavioral Analysis (CCABA). CCABA treats children on the spectrum using evidence-based treatment methods. With the impact of COVID, let’s say HGAPS agreed to make a wiki page for CCABA specifically describing how to do telepsychology with autistic clients. HGAPS has pages for “Autism,” “Telepsychology,” and "COVID". Transclusion can be used to selectively choose specific and relevant sections from each to create a page for “Telepsychology and Autism during the COVID crisis.” This would save many hours of work as the wheel has already been invented.

## Warnings for Transclusion
### Chances for Great Errors

Due to the potential for being able to edit high volumes of pages with a single click, it is important to take great care when editing transcluded source pages. Make use of your sandbox to get things right the first time! That will save a lot of headache in the future. It is important to get a very good understanding of transclusion before attempting to edit HGAPS pages. It is also important to get the "okay" from relevant HGAPS admin before attempting to edit pages with high transclusion rates. This is accomplished through clear communication with necessary individuals.

### The Need for A Curator

Special care is needed when creating highly public pages using a common transclusion page, such as our banner functionality. Currently, we are waiting on full roll out of our banner page until we have the common transclusion page specially protected from editing. In wikiversity, there are two types of protections that prevent people from editing a page: Full protection and partial protection. Partial protection only allows verified Wikiversity members to make edits to the page, while full protection only allows admins to make edits to the page. For something like our banner page, we want to get someone in HGAPS into an admin roll, namely the Curator position. If that is a conflict of interest, it would be necessary to have an already established curator who understands the importance of quick edits to our pages (say, if we are trying to get out emergency information in the time of a crisis that might potentially save lives). Curators are the lowest rung of the Wikiversity admin ladder and have the privilege to fully protect pages as well as edit protected pages. Transclusion within HGAPS cannot be used to the fullest extent in some cases due to the potential for griefers to edit vast amounts of pages with single common pages. We are currently working on finding the best way to get HGAPS into the Curator position or to find a close Curator in order to fully roll out banner functionality in a Wiki-approved and ethical way.