2023年8月18日 星期五

SC 的 sc_include_library()、sc_url_library() MACRO

SC 做好一些現成的 Macros 可以使用。其中:

sc_include_library("Target", "Library Name", "File", "include_once", "Require")

This macro includes a PHP file from a library in the application. You must have a library created in Scriptcase to make use of this macro. To create a library, go to "Tools -> Libraries".

Parameter
Description
TargetTells you what the scope of the library. It can be "sys" for libraries of Public scope or "prj" for libraries of the Project scope.
Library NameName given to the library at the time of creation.
FileThe absolute path within the library.
include_once (optional)Make sure that the file will only be included once. If not informed, this value is set as "true".
Require (optional)If the file or library does not exist, the application to be executed and returns an error. If not informed, the value is set as "true".

 

 

Ex: Including a file from a library:
sc_include_library("prj", "phpqrcode", "qrlib.php", true, true);



這是 External Library。
剛才試了 自己建 treeview 這個 Library,
裡面有一個 .css、一個 .js、 一個 .php、還有一個 images/tree/... 裡面的一個些圖檔

在 css 中,會用到這些圖檔,如下:
ul#n_0 {
padding-left: 0px !important;
background-image: url(images/tree/blank.gif) !important;
}

注意,那個 url(images/tree/blank.gif) 的 相對位址 images ,就直接在 Library 裡面建立 images/tree/ 的資料夾放置那些圖檔。

在SC 程式中要引用的時候,用法:

<link rel="stylesheet" type="text/css" href="<?php echo sc_url_library('prj', 'treeview', 'treeview.css'); ?>">
<script type="text/javascript" src="<?php echo sc_url_library('prj', 'treeview', 'tree.js'); ?>"></script>

這樣用。

另外,還有一個:

sc_include_library("prj", "treeview", "treeview_m.class.php", true, true);

我使用smarty 也是用這個:

// SMARTY

// Start output buffering
ob_start();
// run code in x.php file
// ...
// echo "<html><hrad></head><body>hello world!</body></html>";

sc_include_library("sys", "smarty", "Smarty.class.php", true, true);
// NOTE: Smarty has a capital 'S'
// require_once('Smarty.class.php');
$smarty = new Smarty();

$v_66shop_link = get_66shop_link_url("guest");

$smarty->assign('v_66shop_link_url',$v_66shop_link);

//** un-comment the following line to show the debug console
//$smarty->debugging = true;

$smarty->display('../_Designs/hongfu/index.html');
//echo $smarty->fetch('c:/temp/matrix_adm/html/index.html');

// saving captured output to file
// file_put_contents('c:/temp/filename.htm', ob_get_contents());
// end buffering and displaying page
ob_end_flush();

這兩個  Library 的用法,注意一下。






沒有留言:

張貼留言

如何判斷現在FORM是在 insert mode? 還是 update mode?

只要用  if (empty({primary_key})) 就可以知道是否為新增模式了。 如果 {promary_key} 是空白的,那麼就是在新增模式;反之,就是更新模式。 以上。