W3TPL/recipes: Difference between revisions
< W3TPL
Jump to navigation
Jump to search
(New page: ==Listing Pages in a Category== This bit is for a feature-in-development. I'll probably be adding full SQL capability at some point, but I want to make sure it is secure (and can be disabl...) |
(→Listing Pages in a Category: wikitext - working example) |
||
Line 1: | Line 1: | ||
==Listing Pages in a Category== | ==Listing Pages in a Category== | ||
This bit is for a feature-in-development. I'll probably be adding full SQL capability at some point, but I want to make sure it is secure (and can be disabled in LocalSettings) before putting it in; for now, W3 is going to have data access only by filtering tables -- which can also be data views, i.e. potentially very complex SQL but only if you have db permission to create views. | This bit is for a feature-in-development. I'll probably be adding full SQL capability at some point, but I want to make sure it is secure (and can be disabled in LocalSettings) before putting it in; for now, W3 is going to have data access only by filtering tables -- which can also be data views, i.e. potentially very complex SQL but only if you have db permission to create views. | ||
===SQL=== | |||
<mysql>CREATE OR REPLACE VIEW qryW3_Titles_Catgs AS | <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;</mysql> | categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id;</mysql> | ||
* 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=== | |||
<pre> | |||
<let name=including val="1" /> | |||
</hide><for table="qryW3_Titles_Catgs" where="(cl_to='Data/target') AND (page_namespace=0)" name=pg> | |||
<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> | |||
</pre> | |||
* Replace "Data/target" with the name of the category you want to list | |||
* Alter the line which begins with {{xmltag|1=get name=title_link /}} (i.e. everything between the {{xmltag|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. |
Revision as of 16:14, 14 September 2008
Listing Pages in a Category
This bit is for a feature-in-development. I'll probably be adding full SQL capability at some point, but I want to make sure it is secure (and can be disabled in LocalSettings) before putting it in; for now, W3 is going to have data access only by filtering tables -- which can also be data views, i.e. potentially very complex SQL but only if you have db permission to create views.
SQL
<mysql>CREATE OR REPLACE VIEW qryW3_Titles_Catgs AS
SELECT * FROM categorylinks AS cl LEFT JOIN page AS p ON cl_from=page_id;</mysql>
- 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> <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 Template:Xmltag (i.e. everything between the Template:Xmltag 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.