I have made a website by myself. now I need to add the static function template file & lt; divclass = & quot; mz_product_right_2 & quot; & gt; // The following is the database query tag {mzrui: listtable = 'product' order = 'uiddesc'} & lt ask PHP to generate a static page and how to return to the path
I made my own website and now I need to add static features
Template File
// The following is the query tag of the database.
{Mzrui: list table = 'product' order = 'uid desc '}
{$ Prod_id ['name']}
{/Mzrui}
{$ V ['typedir']} returns the path of the current database column.
Now the problem is that the path is not all static when static, and some such as comments, and some places that need to be updated frequently must use dynamic paths.
The same parsing function is used for both static parsing templates in the background and dynamic parsing templates.
Public static function mzrui_tag ($ tab, $ SQL) // mysql parsing
{
Global $ mz_mysql, $ prefix;
Preg_match_all ("/([a-z] +) \ = [\ ']? ([^ \ '] +) [\']? /I ", stripslashes ($ SQL), $ matches, PREG_SET_ORDER );
$ Check = array ('type', 'rows ', 'table', 'order', 'limit ');
Foreach ($ matches as $ v)
{
If (in_array ($ v [1], $ check ))
{
$ V [1] = $ v [2]; // variable
}
}
Switch ($ tab)
{
Case 'channel': // navigation bar label
{
$ Result = $ mz_mysql-> SQL ("select * from". $ prefix. "kind where kind = 0 ");
While ($ v = mysql_fetch_array ($ result ))
{
If ($ v ['HTML '] = 0) // here, it is determined that if no Static column is generated, a dynamic link is returned. Otherwise, the static folder address in the database is obtained.
{
$ V ['typedir'] = 'index. php? Ac = list & id = '. $ v ['uid'];
$ Str [] = $ v;
}
}
$ GLOBALS ['data'] = $ str;
}
Break;
Case 'List': // topic tag
{
If (! Empty ($ _ GET ['id']) // if the link is dynamic, the id of the current category column is used. However, if a static page is generated in the background, there is a problem here
{
$ Id = $ mz_mysql-> SQL ("select * from". $ prefix. "kind where uid =". $ _ GET ['id']);
}
}
Break;
}
Return' '; // Return data
}
Now we need to solve the problem of returning the path and the topic ID. now the idea is confusing. forget to give some advice with experience.
------ Solution --------------------
Are you using cms? If it's all written by myself, it's impossible.
Static: it's easy to put the output variable into a file in the specified format (html,
The file_put_contents () or fwrite () functions can all be used. when put, you must specify the path strength.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.