当前位置:网站首页>PHP notes - use Smarty to set public pages (include, if, else, variable settings)
PHP notes - use Smarty to set public pages (include, if, else, variable settings)
2022-07-02 02:34:00 【IT1995】
The main effects are as follows , The login page :
The top is the public page . After logging in users, it's like this .
After successful login , Which homepage is at the top 、 fund 、 gold 、 The stocks are all coming out . And you can click different tabs active, as follows :
fund :
gold :
Stocks :
The realization is like this , Extract the public page :
as follows header.html
<header class="mb-auto">
<div>
<h3 class="float-md-start mb-0"> Financial simulation system <span class="badge bg-light text-dark">Beta V1.0.0</span></h3>
{if $login}
<nav class="nav nav-masthead justify-content-center float-md-end">
<a href="index.php?p=user&c=dashboard&a=index" {if $activeItem == 1} class="nav-link active" {else} class="nav-link" {/if}> home page </a>
<a href="index.php?p=user&c=fund&a=index" {if $activeItem == 2} class="nav-link active" {else} class="nav-link" {/if}> fund </a>
<a href="index.php?p=user&c=gold&a=index" {if $activeItem == 3} class="nav-link active" {else} class="nav-link" {/if}> gold </a>
<a href="index.php?p=user&c=stock&a=index" {if $activeItem == 4} class="nav-link active" {else} class="nav-link" {/if}> Stocks </a>
</nav>
{/if}
</div>
</header>
there login It's a variable , When quoted login by true be , Show the options in the background .
$activeItem It's also a variable , His value is 1,2,3,4, Respectively means the home page 、 fund 、 gold 、 Stocks .
It contains :
The login page contains :
{include file="public/header.html" login=false}
The background page contains :
{include file="public/header.html" activeItem=1 login=true}
What to pay attention to :
①include Variables can be passed in ;
②{if} To be used after completion {/if} Otherwise, the script language cannot judge where it ends .
边栏推荐
- 【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度
- Kibana controls es
- AcWing 245. Can you answer these questions (line segment tree)
- How to batch add background and transition effects to videos?
- [learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
- Stack - es - official documents - filter search results
- Summary of some experiences in the process of R & D platform splitting
- CSDN article underlined, font color changed, picture centered, 1 second to understand
- 【liuyubobobo-玩转Leetcode算法面试】【00】课程概述
- Infix expression to suffix expression (computer) code
猜你喜欢
附加:信息脱敏;
How to turn off the LED light of Rog motherboard
Comparative analysis of MVC, MVP and MVVM, source code analysis
Webgpu (I): basic concepts
AR增强现实可应用的场景
Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
LFM signal denoising, time-frequency analysis, filtering
CSDN article underlined, font color changed, picture centered, 1 second to understand
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
Batch detect whether there is CDN in URL - high accuracy
随机推荐
[deep learning] Infomap face clustering facecluster
Deployment practice and problem solving of dash application development environment based on jupyter Lab
Yyds dry goods inventory accelerating vacuum in PG
Formatting logic of SAP ui5 currency amount display
Bash bounce shell encoding
es面试题
2022安全员-C证考试题及模拟考试
【做题打卡】集成每日5题分享(第二期)
An analysis of circuit for quick understanding
【无标题】
STM32__ 05 - PWM controlled DC motor
JS slow animation
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
Sword finger offer 62 The last remaining number in the circle
How does MySQL solve the problem of not releasing space after deleting a large amount of data
[pit] how to understand "parameter fishing"
Infix expression to suffix expression (computer) code
Pytest testing framework
Cesium dynamic diffusion point effect