W3TPL/recipes: Difference between revisions
< W3TPL
Jump to navigation
Jump to search
m (→Wikitext: +hide (now required for using echo tags)) |
m (format fixes) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== | ==Pages and Categories== | ||
List all categorized Titles without defining any VIEWs: | |||
===Wikitext=== | |||
<syntaxhighlight lang=xml> | |||
<hide> | |||
<for sql="SELECT * FROM categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id"> | |||
<let name=pg_title val=@row.page_title /> | |||
<let name=out append> | |||
* [[</let> | |||
<let name=out append copy=pg_title /> | |||
<let name=out append>|</let> | |||
<let load page=$pg_title name=data /> | |||
<let name=out append copy=data[summary] /> | |||
<let name=out append>]]</let> | |||
</for> | |||
</hide><get name=out /> | |||
</syntaxhighlight> | |||
List all Titles in a specific category: | |||
===SQL=== | ===SQL=== | ||
<mysql>CREATE OR REPLACE VIEW qryW3_Titles_Catgs AS | <syntaxhighlight lang=mysql>CREATE OR REPLACE VIEW qryW3_Titles_Catgs AS | ||
SELECT * FROM | SELECT * FROM | ||
categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id;</ | categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id;</syntaxhighlight> | ||
* Very similar to the [http://semeb.com/dpldemo/index.php?title=DPL:Installation dpl_clview] view used by DPL | * Very similar to the [http://semeb.com/dpldemo/index.php?title=DPL:Installation dpl_clview] view used by DPL | ||
===Wikitext=== | ===Wikitext=== | ||
< | <syntaxhighlight lang=xml> | ||
<let name=including val="1" /> | <let name=including val="1" /> | ||
</hide><for table="qryW3_Titles_Catgs" where="(cl_to='Data/target') AND (page_namespace=0)" name=pg hide> | </hide><for table="qryW3_Titles_Catgs" where="(cl_to='Data/target') AND (page_namespace=0)" name=pg hide> | ||
Line 21: | Line 40: | ||
* <get name=title_link />: "<get name=title />": <get name=source /></echo> | * <get name=title_link />: "<get name=title />": <get name=source /></echo> | ||
</for> | </for> | ||
</ | </syntaxhighlight> | ||
* Replace "Data/target" with the name of the category you want to list | * Replace "Data/target" with the name of the category you want to list | ||
* Alter the line which begins with {{ | * Alter the line which begins with {{xml/tag|1=get name=title_link /}} (i.e. everything between the {{xml/tag|echo}} tags) to display what you want; "title" and "source" are from an actual live installation ([[PsyCrit]]) and are defined within the pages in that category, so each output line gives a little information about the page (effectively a mini-"[[dataset report|report]]") | ||
* The "including" variable tells the included pages not to show their category, so that this page won't think it is also in that same category. | * The "including" variable tells the included pages not to show their category, so that this page won't think it is also in that same category. | ||
To use the same data to generate a form with a drop-down list of all titles returned: | |||
<syntaxhighlight lang=xml><func xmltag contents> | |||
<let name=out chr=60 /> | |||
<let name=out append copy=contents /> | |||
<let name=out append chr=62 /> | |||
<echo><get name=out raw /></echo> | |||
</func> | |||
<call xmltag contents="form" /> | |||
<call xmltag contents="SELECT NAME=target" /> | |||
<for table="qryW3_Titles_Catgs" where="(cl_to='Data/target') AND (page_namespace=0)" sort="page_title DESC" name=pg hide> | |||
<let name=pg_title val="@row.pg.page_title" /> | |||
<load page=$pg_title /> | |||
<echo><call xmltag contents="OPTION" /><get name=keyname /> - <get name=title /><call xmltag contents="/OPTION" /></echo> | |||
</for> | |||
<call xmltag contents="/SELECT" /> | |||
<call xmltag contents="/form" /> | |||
</syntaxhighlight> |
Latest revision as of 19:12, 15 April 2022
Pages and Categories
List all categorized Titles without defining any VIEWs:
Wikitext
<hide>
<for sql="SELECT * FROM categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id">
<let name=pg_title val=@row.page_title />
<let name=out append>
* [[</let>
<let name=out append copy=pg_title />
<let name=out append>|</let>
<let load page=$pg_title name=data />
<let name=out append copy=data[summary] />
<let name=out append>]]</let>
</for>
</hide><get name=out />
List all Titles in a specific category:
SQL
CREATE OR REPLACE VIEW qryW3_Titles_Catgs AS
SELECT * FROM
categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id;
- Very similar to the dpl_clview view used by DPL
Wikitext
<let name=including val="1" />
</hide><for table="qryW3_Titles_Catgs" where="(cl_to='Data/target') AND (page_namespace=0)" name=pg hide>
<let name=pg_title val="@row.pg.page_title" />
<load page=$pg_title />
<let name=title_link>[[</let>
<let name=title_link append copy=pg_title />
<let name=title_link append>|</let>
<let name=title_link append copy=keyname />
<let name=title_link append>]]</let>
<echo>
* <get name=title_link />: "<get name=title />": <get name=source /></echo>
</for>
- Replace "Data/target" with the name of the category you want to list
- Alter the line which begins with <get name=title_link /> (i.e. everything between the <echo> tags) to display what you want; "title" and "source" are from an actual live installation (PsyCrit) and are defined within the pages in that category, so each output line gives a little information about the page (effectively a mini-"report")
- The "including" variable tells the included pages not to show their category, so that this page won't think it is also in that same category.
To use the same data to generate a form with a drop-down list of all titles returned:
<func xmltag contents>
<let name=out chr=60 />
<let name=out append copy=contents />
<let name=out append chr=62 />
<echo><get name=out raw /></echo>
</func>
<call xmltag contents="form" />
<call xmltag contents="SELECT NAME=target" />
<for table="qryW3_Titles_Catgs" where="(cl_to='Data/target') AND (page_namespace=0)" sort="page_title DESC" name=pg hide>
<let name=pg_title val="@row.pg.page_title" />
<load page=$pg_title />
<echo><call xmltag contents="OPTION" /><get name=keyname /> - <get name=title /><call xmltag contents="/OPTION" /></echo>
</for>
<call xmltag contents="/SELECT" />
<call xmltag contents="/form" />