ComboStrap - Page Sql

About

page sql is a SELECT sql syntax that permits to select pages and return page attribute used in a template iterator.

Example

Syntax

Select

'SELECT'  \
[ 'WHERE' predicate {',' predicate } ] \
[ 'ORDER BY' attribute ('ASC'|'DESC')? {',' attribute ('ASC'|'DESC')?} ] \
[ limit 'Number' ] ;

Attribute

The attribute are defined in the page attribute

Predicate

A predicate takes the below form:

filter-attribute  ( ('='|'!=')  'value' ||  ['NOT'] ('GLOB' glob-pattern | 'LIKE'  like-pattern  ['ESCAPE' 'char']))

filter-attribute

If your sqlite does not support Json, you can't filter on manually added metadata, otherwise you can filter on all attributes

glob-pattern

GLOB pattern matching is case sensitive and uses the Unix file globbing syntax for its wildcards:

  • * matches any number of characters (including none)
  • ? matches exactly one character.
  • [] specify a set of single characters or, when the hyphen character - is used, a range of characters. Example: [aeiou] matches any lowercase vowel, [0-9] matches any digit.
  • the backslash character \ is the escape character. ie \\ matches a single backslash, \? matches the question mark.
  • any other characters match itself.

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:url:404 - ComboStrap URL - Missing Page (404)

like-pattern

The LIKE is not case sensitive and in the pattern expression:

  • % matches any sequence of zero or more characters
  • _ matches any single character.
  • any other characters match itself.

example: If you want to get:

  • the path and title of all pages
  • that have the terms image, svg or raster in their path

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:svg How to use a SVG in ComboStrap
:docs:performance:svg_optimization Svg Optimization included
:docs:content:raster Raster Image in ComboStrap (jpg, png, ...)
:docs:semantic:image ComboStrap Page Metadata - Image
:docs:content:page-image Page-image Component: Renders the illustrative image of your page

Limit

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:url:page_rules 2021-10-16T13:07:20+00:00
:docs:url:redirection 2021-10-16T12:59:06+00:00
:docs:styling:color 2021-10-08T19:49:09+00:00
:docs:quality:dynamic_monitoring 2021-10-07T11:40:53+00:00
Powered by ComboStrap