Closed amrutadotorg closed 4 weeks ago
Any variable that you set before run_sql will be accessible from the sql file being run.
So you could simply do
set title = 'hello';
SELECT 'dynamic' AS component,
sqlpage.run_sql('shell.sql')
AS properties;
and in shell.sql
select 'shell' as component, $title as title;
thank you, it works!
is there a way to set a default title if $title is not set? something like:
SELECT 'shell' AS component, COALESCE($title, 'default_title') AS title;
or
SELECT 'shell' AS component,
CASE
WHEN $title IS NULL THEN 'default_title'
ELSE $title
END AS title;
yes, both should work
It works only if I remove from the shell
18 as 'font_size'
otherwise I'm getting the error
18 as font_size, not 18 as 'font_size'
Single quotes are for string literals, not column names.
thank you
Hi on each page I have
I was wondering how to change the page title based on the visited page. Right now, it’s static. Is there a way to pass a variable (like post_id) to the shell component? I couldn’t find any examples in the documentation.
thank you
my shell
sql.sql
: