HOWTO Working with HTML Articles in Lianja 9.4
by
, 2023-10-14 at 08:32 (56576 Views)
Lianja 9.4 (9.4.3) supports the ability to Create, Edit and Display HTML Articles in an ArticleView section or in the Report Viewer.
Articles are HTML formatted files that can contain {macros} and other embedded content which are substituted when displayed.
Articles are embedded in an ArticleView and are dynamically generated. They can be used in Desktop, Web and Mobile Apps.
Uses of Articles
Articles have a variety of uses including:
- The home page or tab for your apps
- Custom data bound presentation
- Email and/or print letters, receipts, quotations, proposals etc from within your apps containing dynamic data e.g customer names, details, order summary etc
- Build data-driven web sites
Here's an example ArticleView (example_datamerge App) included in the distro
Creating an ArticleView
From the Form Tools choose “ArticleView” from the “Section” menu.
Creating an Article
Click the “New Article” button to create a new article or the “Edit Article” button to select an existing article to display in the ArticleView.
Editing an Article
Adding dynamic content using Article Macros
You can add dynamic content to the article using {macro}.
The macro enclosed in the {..} can be any valid LianjaScriot expression.
Typically the expression will reference columns in a table that is open.
e.g
Code:{employees.lastname}You can also perform more complex calculations by creating your own LianjaScript custom functions in the Apps workspace and include these with parameters in the {macro}.Code:{proper(employees.lastname)}
These custom functions can use SQL to calculate values that will be substituted into the Article.
Note that when run in Web/Mobile these functions will have no data context as they are executed on the server. You should use PUSH/POP DATASESSION and OPEN DATABASE to ensure the correct data state.
Adding dynamic content by embedding WebViewWidgets
To keep coding (No-Code and Low-Code) to a minimum there are many built-in WebViewWidgets that can used in Articles. Becoming familiar with these will speed up your development so it’s worth spending time to get to know them. You can study the code behind these to build your own custom WebViewWidgets.
Adding dynamic data tables
Specify the {webview:lib:/datalistview.rsp} WebViewWidget to embed a database!table with specific columns and filter using the filter=odataexpr parameter.
Example:
Code:{webview:lib:/datalistview.rsp?database=southwind&table=customers&columns=customerid,contactname,companyname}
Adding dynamic images
Specify the {webview:lib:/imageview.rsp} WebViewWidget to embed an image from a database!table.column.
Example:
Code:{webview:lib:/imageview.rsp?database=southwind&table=employees&column=photo&width=240px&height=240px&filter=lastname eq "{{employees.lastname}}"}
Adding dynamic Charts
Specify the {webview:lib:/chartview.rsp} WebViewWidget to embed a chart into an article.
Example:
Code:{webview:lib:/chartview.rsp?charttype=bar&caption=Vacation days&labels=Q1,Q2,Q3,Q4&data=15,10,20,6}
Adding custom WebViewWidgets
You can create your own custom WebViewWidgets and embed them in an Article.
A WebViewWidget can be coded in LianjaScript (.rsp file), Python (.pysp file) or JavaScript (.jssp file).
These custom files should be created in the Apps workspace.
See the developing custom WebViewWidgets documentation.
You can embed your custom WebViewWidgets with arguments like this:
Emailing an ArticleCode:{webview:yourfilename.rsp?arg1=value&arg2=value…}
You can Email and Print articles using the Report Viewer.
Printing an Article
Enable the "Print button" in the section header. Click it to print.
Deploying an Article
Articles need to be deployed from the "Deploy" workspace to be accessible at runtime in Desktop, Web or Mobile.