page sql is a SELECT sql syntax that permits to select pages and return page attribute used in a template iterator.
A page select should follow the following railroad diagram.
'SELECT' [ from ] \ [ 'WHERE' predicate {',' predicate } ] \ [ ('ORDER BY' attribute ('ASC'|'DESC')? {',' attribute ('ASC'|'DESC')?}) | 'ORDER RANDOM' ] \ [ limit 'Number' ] ;
The from clause permits to set where the page data comes from.
' FROM' ('pages'|'backlinks'|'descendants')
where:
The from clause is is facultative. The selection will use the pages table if the from clause is not found.
The attribute are defined in the page attribute
A predicate is a filter that will reduce the set of pages and takes the below form:
filter-attribute ( ('='|'!=') 'value' || ['NOT'] ('GLOB' glob-pattern | 'LIKE' like-pattern ['ESCAPE' 'char']))
If your sqlite does not support Json, you can't filter on manually added metadata, otherwise you can filter on all attributes
GLOB pattern matching is case sensitive and uses the Unix file globbing syntax for its wildcards:
Subpatterns are not supported by Sqlite (ie {sun,moon,stars} to match sun, moon, or stars)
example: the path and title of all pages that ends with 3 digits.
select where path glob '*[0-9][0-9][0-9]'
This sql returns the following data for this website.
Page |
---|
:docs:router:404 - What is a missing page (404) and how ComboStap solve them |
The LIKE is not case sensitive and in the pattern expression:
example: If you want to get:
you would use the following page sql:
select where path like '%image%' or path like '%svg%' or path like '%raster%'
This page sql will return the following pages for this website.
Pages | Title |
---|---|
:docs:content:image | How to use the image tag in ComboStrap |
:docs:content:page-image | Page-image Component: Renders the illustrative image of your page |
:docs:content:raster | Raster Image in ComboStrap (jpg, png, ...) |
:docs:content:svg | How to use a SVG in ComboStrap |
:docs:page:featured-image | Featured Image |
:docs:page:first-image | First image |
:release:deprecated:images-meta | The page image metadata |
:docs:performance:svg_optimization | Svg Optimization included |
:howto:image:same_dimension | How to get a serie of images with the same dimension (Width and Height) ? |
:howto:image_center | How to center an image ? |
You can use:
Example:
select from pages where date_end >= now order by date_start asc
select from pages where date_modified >= date('now','-7 days') order by date_modified asc
The limit clause permits to return the first rows. It's mostly used in Recent statement such as the last pages recently modified or created.
Example: If you want to get the last 4 pages along with the modification date and the path, you would execute this query:
select order by date_modified desc limit 4
This sql returns the following pages for this website.
Pages | Date Modified |
---|---|
:docs:admin:cli | Friday, November 22, 2024 |
:docs:admin:docker | Friday, November 22, 2024 |