Difference between revisions of "Template:Forum url"

From FlightGear wiki
Jump to: navigation, search
(Anchoring fix - the post anchoring is now at the very end of the URI, and only if 'p' has been supplied and 'anchor' has not.)
(Template expansion to add support for listing all forum members and complex forum searches. The 'type' parameter has been added to switch between 'view', 'member', and 'search' modes. This allows for easy expansion for links to other forum URLs.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{project infrastructure|forum|link=no}}<!--
 
{{project infrastructure|forum|link=no}}<!--
  -->{{#if: {{{f|{{{t|{{{p|{{{anchor|{{{hilit|}}}}}}}}}}}}}}}
+
-->{{#switch: {{{type|view}}}
      | {{#if: {{{t|{{{p|{{{anchor|{{{hilit|}}}}}}}}}}}}
+
    | view = <!--
          | /viewtopic.php? <!-- Add viewtopic.php if any parameters, excluding 'f', are supplied. -->
+
      -->{{#if: {{{f|{{{t|{{{p|{{{anchor|{{{hilit|}}}}}}}}}}}}}}}
          | /viewforum.php? <!-- Add viewforum.php if only the 'f' parameter is supplied. -->
+
            | {{#if: {{{t|{{{p|{{{anchor|{{{hilit|}}}}}}}}}}}}
 +
                | /viewtopic.php? <!-- Add viewtopic.php if any parameters, excluding 'f', are supplied. -->
 +
                | /viewforum.php? <!-- Add viewforum.php if only the 'f' parameter is supplied. -->
 +
              }}
 +
        }}<!--
 +
      -->{{#if: {{{f|}}}
 +
          | f={{{f}}}<!--
 +
          -->{{#if: {{{t|{{{p|{{{hilit|}}}}}}}}} | &}}<!-- Add an ampersand if t, p or hilit are present afterwards. -->
 +
        }}<!--
 +
      -->{{#if: {{{t|}}}
 +
          | t={{{t}}}<!--
 +
          -->{{#if: {{{p|{{{hilit|}}}}}} | &}}<!-- Add an ampersand if p or hilit are present afterwards -->
 +
        }}<!--
 +
      -->{{#if: {{{p|}}}
 +
          | p={{{p}}}<!--
 +
          -->{{#if: {{{hilit|}}} | &}}<!-- Add an ampersand if hilit is present afterwards -->
 +
        }}<!--
 +
      -->{{#if: {{{hilit|}}}
 +
          | hilit={{{hilit}}}
 +
        }}<!--
 +
      -->{{#if: {{{anchor|{{{p|}}}}}}<!-- Post anchoring -->
 +
          | &#35;{{#if: {{{anchor|}}}
 +
                    | {{{anchor}}}
 +
                    | p{{{p}}}
 +
                  }}
 
         }}
 
         }}
     }}<!--
+
     | member = <!--
  -->{{#if: {{{f|}}}
+
       -->/memberlist.php<!-- Base phpBB file.
      | f={{{f}}}<!--
+
       -->{{#if: {{{u|}}}
       -->{{#if: {{{t|{{{p|{{{hilit|}}}}}}}}} | &}}<!-- Add an ampersand if t, p or hilit are present afterwards. -->
+
          | ?mode=viewprofile&u={{{u}}} <!-- URI component required for showing a user -->
    }}<!--
+
  -->{{#if: {{{t|}}}
+
      | t={{{t}}}<!--
+
       -->{{#if: {{{p|{{{hilit|}}}}}} | &}}<!-- Add an ampersand if p or hilit are present afterwards -->
+
    }}<!--
+
  -->{{#if: {{{p|}}}
+
      | p={{{p}}}<!--
+
      -->{{#if: {{{hilit|}}} | &}}<!-- Add an ampersand if hilit is present afterwards -->
+
    }}<!--
+
  -->{{#if: {{{hilit|}}}
+
      | hilit={{{hilit}}}
+
    }}<!--
+
  -->{{#if: {{{anchor|{{{p|}}}}}}<!-- Post anchoring -->
+
      | &#35;{{#if: {{{anchor|}}}
+
          | {{{anchor}}}
+
          | p{{{p}}}
+
 
         }}
 
         }}
     }}<noinclude>
+
     | search = <!--
 +
      -->/search.php<!-- Base phpBB file.
 +
      -->{{#if: {{{keywords|}}}
 +
          | ?keywords={{{keywords}}}
 +
        }}<!--
 +
      -->{{#if: {{{f|}}}
 +
          | &fid&#91;&#93;={{{f}}}
 +
        }}<!--
 +
      -->{{#if: {{{t|}}}
 +
          | &t={{{t}}}
 +
        }}<!--
 +
-->}}<noinclude>
 
{{Informative template|1=
 
{{Informative template|1=
 
== Goal ==
 
== Goal ==
Line 35: Line 54:
  
 
  {{obr}}'''forum url'''
 
  {{obr}}'''forum url'''
  {{!}} ''f''     =
+
{{!}} ''type''    =
  {{!}} ''t''     =
+
  {{!}} ''f''       =
  {{!}} ''p''     =
+
  {{!}} ''t''       =
  {{!}} ''anchor'' =
+
  {{!}} ''p''       =
  {{!}} ''hilit''  =
+
  {{!}} ''anchor''   =
 +
  {{!}} ''hilit''   =
 +
  {{!}} ''keywords'' =
 
  {{cbr}}
 
  {{cbr}}
  
; f: Forum number to be passed to phpBB's viewtopic.php (optional).
+
; type: The forum interface type that can be one of:
  
; t: Thread number to be passed to phpBB's viewtopic.php (optional).
+
:; view: The default value.  This is used for URLs to posts, topics, and posts, via phpBB's <code>viewforum.php</code> or <code>viewtopic.php</code>.
  
; p: Post number to be passed to phpBB's viewtopic.php (optional).
+
:; member: For URLs of a user on the forum, via phpBB's <code>memberlist.php</code>.  This value will cause the {{param|f}}, {{param|t}}, {{param|p}}, {{param|anchor}}, and {{param|hilit}} parameters to be ignored.
  
; anchor: HTML anchor, used for jumping to posts (optional).
+
:; search: For URLs performing forum searches, via phpBB's <code>search.php</code>.  This value will cause the {{param|p}}, {{param|anchor}}, and {{param|hilit}} parameters to be ignored.
  
; hilit: Words on the forum posts to be highlighted (optional).  Words should be separated by the plus character "+".
+
; f: Forum number (optional).  Used with the {{param|type}} values of {{param||view}} and {{param||search}}.
 +
 
 +
; t: Topic number (optional).  Used with the {{param|type}} values of {{param||view}} and {{param||search}}.
 +
 
 +
; p: Post number (optional).  Used with the {{param|type}} value of {{param||view}}.
 +
 
 +
; anchor: HTML anchor, used for jumping to posts (optional).  Used with the {{param|type}} value of {{param||view}}.
 +
 
 +
; hilit: Words on the forum posts to be highlighted (optional).  Words should be separated by the plus character "+".  Used with the {{param|type}} value of {{param||view}}.
 +
 
 +
; u: User number (optional).  Used with the {{param|type}} value of {{param||member}}.
 +
 
 +
; keywords: The keywords to perform a forum search with (optional).  Words should be separated by the plus character "+".  Used with the {{param|type}} value of {{param||search}}.
  
 
== Technical details ==
 
== Technical details ==
Line 64: Line 97:
 
{{forum url}}
 
{{forum url}}
  
=== A subforum (The FlightGear project) ===
+
=== View mode ===
 +
 
 +
==== A subforum (The FlightGear project) ====
  
 
  {{obr}}forum url{{!}}f=42{{cbr}}
 
  {{obr}}forum url{{!}}f=42{{cbr}}
Line 70: Line 105:
 
{{forum url|f=42}}
 
{{forum url|f=42}}
  
=== A topic (FlightGear Newsletter) ===
+
==== A topic (FlightGear Newsletter) ====
  
 
  {{obr}}forum url{{!}}t=7794{{cbr}}
 
  {{obr}}forum url{{!}}t=7794{{cbr}}
Line 76: Line 111:
 
{{forum url|t=7794}}
 
{{forum url|t=7794}}
  
=== A post (Re: Marking topics as "solved") ===
+
==== A post (Re: Marking topics as "solved") ====
  
 
  {{obr}}forum url{{!}}p=111333{{cbr}}
 
  {{obr}}forum url{{!}}p=111333{{cbr}}
Line 82: Line 117:
 
{{forum url|p=111333}}
 
{{forum url|p=111333}}
  
=== Subforum, topic and post ===
+
==== Subforum, topic and post ====
  
 
{{note|The {{param|f}} and {{param|t}} parameters are redundant in this URL.}}
 
{{note|The {{param|f}} and {{param|t}} parameters are redundant in this URL.}}
Line 90: Line 125:
 
{{forum url|f=8|t=10805|p=111333}}
 
{{forum url|f=8|t=10805|p=111333}}
  
=== Topic and post ===
+
==== Topic and post ====
  
 
{{note|The {{param|t}} parameter is redundant in this URL.}}
 
{{note|The {{param|t}} parameter is redundant in this URL.}}
Line 98: Line 133:
 
{{forum url|t=10805|p=111333}}
 
{{forum url|t=10805|p=111333}}
  
=== Anchoring ===
+
==== Anchoring ====
  
 
  {{obr}}forum url{{!}}t=10805{{!}}anchor=p111333{{cbr}}
 
  {{obr}}forum url{{!}}t=10805{{!}}anchor=p111333{{cbr}}
Line 104: Line 139:
 
{{forum url|t=10805|anchor=p111333}}
 
{{forum url|t=10805|anchor=p111333}}
  
=== Highlighting ===
+
==== Highlighting ====
  
 
  {{obr}}forum url{{!}}t=10805{{!}}hilit=board+index{{cbr}}
 
  {{obr}}forum url{{!}}t=10805{{!}}hilit=board+index{{cbr}}
Line 110: Line 145:
 
{{forum url|t=10805|hilit=board+index}}
 
{{forum url|t=10805|hilit=board+index}}
  
==== Highlight a post ====
+
===== Highlight a post =====
  
 
  {{obr}}forum url{{!}}p=111333{{!}}hilit=contains+a+problem{{cbr}}
 
  {{obr}}forum url{{!}}p=111333{{!}}hilit=contains+a+problem{{cbr}}
  
 
{{forum url|p=111333|hilit=contains+a+problem}}
 
{{forum url|p=111333|hilit=contains+a+problem}}
 +
 +
=== Member mode ===
 +
 +
==== Member listing ====
 +
 +
{{obr}}forum url{{!}}type=member{{cbr}}
 +
 +
{{forum url|type=member}}
 +
 +
==== Specific member ====
 +
 +
{{obr}}forum url{{!}}type=member{{!}}u=2{{cbr}}
 +
 +
{{forum url|type=member|u=2}}
 +
 +
=== Search mode ===
 +
 +
==== Search page ====
 +
 +
{{obr}}forum url{{!}}type=search{{cbr}}
 +
 +
{{forum url|type=search}}
 +
 +
==== Search everything ====
 +
 +
{{obr}}forum url{{!}}type=search{{!}}keywords=c172p+floats{{cbr}}
 +
 +
{{forum url|type=search|keywords=c172p+floats}}
 +
 +
==== Search a subforum ====
 +
 +
{{obr}}forum url{{!}}type=search{{!}}f=4{{!}}keywords=c172p+floats{{cbr}}
 +
 +
{{forum url|type=search|f=4|keywords=c172p+floats}}
 +
 +
==== Search a topic ====
 +
 +
{{obr}}forum url{{!}}type=search{{!}}t=25157{{!}}keywords=c172p+floats{{cbr}}
 +
 +
{{forum url|type=search|t=25157|keywords=c172p+floats}}
  
 
== Related templates ==
 
== Related templates ==

Latest revision as of 12:15, 6 June 2019

https://forum.flightgear.org

The following template description is not displayed when the template is inserted in an article.

Goal

This template is used to create URLs for subforums, topics or posts on the FlightGear forum.

Usage

{{forum url
| type     =
| f        =
| t        =
| p        =
| anchor   =
| hilit    =
| keywords =
}}
type
The forum interface type that can be one of:
view
The default value. This is used for URLs to posts, topics, and posts, via phpBB's viewforum.php or viewtopic.php.
member
For URLs of a user on the forum, via phpBB's memberlist.php. This value will cause the f, t, p, anchor, and hilit parameters to be ignored.
search
For URLs performing forum searches, via phpBB's search.php. This value will cause the p, anchor, and hilit parameters to be ignored.
f
Forum number (optional). Used with the type values of view and search.
t
Topic number (optional). Used with the type values of view and search.
p
Post number (optional). Used with the type value of view.
anchor
HTML anchor, used for jumping to posts (optional). Used with the type value of view.
hilit
Words on the forum posts to be highlighted (optional). Words should be separated by the plus character "+". Used with the type value of view.
u
User number (optional). Used with the type value of member.
keywords
The keywords to perform a forum search with (optional). Words should be separated by the plus character "+". Used with the type value of search.

Technical details

The protocol and domain name part of the URI is built using the {{project infrastructure}} template.

Examples

No arguments

{{forum url}}

https://forum.flightgear.org

View mode

A subforum (The FlightGear project)

{{forum url|f=42}}

https://forum.flightgear.org/viewforum.php?f=42

A topic (FlightGear Newsletter)

{{forum url|t=7794}}

https://forum.flightgear.org/viewtopic.php?t=7794

A post (Re: Marking topics as "solved")

{{forum url|p=111333}}

https://forum.flightgear.org/viewtopic.php?p=111333#p111333

Subforum, topic and post

Note  The f and t parameters are redundant in this URL.
{{forum url|f=8|t=10805|p=111333}}

https://forum.flightgear.org/viewtopic.php?f=8&t=10805&p=111333#p111333

Topic and post

Note  The t parameter is redundant in this URL.
{{forum url|t=10805|p=111333}}

https://forum.flightgear.org/viewtopic.php?t=10805&p=111333#p111333

Anchoring

{{forum url|t=10805|anchor=p111333}}

https://forum.flightgear.org/viewtopic.php?t=10805#p111333

Highlighting

{{forum url|t=10805|hilit=board+index}}

https://forum.flightgear.org/viewtopic.php?t=10805&hilit=board+index

Highlight a post
{{forum url|p=111333|hilit=contains+a+problem}}

https://forum.flightgear.org/viewtopic.php?p=111333&hilit=contains+a+problem#p111333

Member mode

Member listing

{{forum url|type=member}}

https://forum.flightgear.org/memberlist.php

Specific member

{{forum url|type=member|u=2}}

https://forum.flightgear.org/memberlist.php?mode=viewprofile&u=2

Search mode

Search page

{{forum url|type=search}}

https://forum.flightgear.org/search.php

Search everything

{{forum url|type=search|keywords=c172p+floats}}

https://forum.flightgear.org/search.php?keywords=c172p+floats

Search a subforum

{{forum url|type=search|f=4|keywords=c172p+floats}}

https://forum.flightgear.org/search.php?keywords=c172p+floats&fid%5B%5D=4

Search a topic

{{forum url|type=search|t=25157|keywords=c172p+floats}}

https://forum.flightgear.org/search.php?keywords=c172p+floats&t=25157

Related templates