123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655 |
- <!DOCTYPE HTML>
- <html lang="" >
- <head>
- <title>语法核心 · GitBook</title>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
- <meta name="description" content="">
- <meta name="generator" content="GitBook 3.2.0">
-
-
-
-
- <link rel="stylesheet" href="../gitbook/style.css">
-
-
-
- <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
-
-
-
- <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
-
-
-
- <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
-
-
-
-
-
-
- <link rel="stylesheet" href="../styles/website.css">
-
-
-
-
-
- <meta name="HandheldFriendly" content="true"/>
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
- <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
-
- <link rel="next" href="piclist.html" />
-
-
- </head>
- <body>
-
- <div class="book">
- <div class="book-summary">
-
-
- <div id="book-search-input" role="search">
- <input type="text" placeholder="Type to search" />
- </div>
-
- <nav role="navigation">
-
- <ul class="summary">
-
-
-
-
-
-
-
- <li class="chapter " data-level="1.1" data-path="../">
-
- <a href="../">
-
-
- Introduction
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.2" data-path="../new/new.html">
-
- <a href="../new/new.html">
-
-
- 新人入职后需要做的工作
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.3" data-path="../host/host.html">
-
- <a href="../host/host.html">
-
-
- 常用HOST
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.4" data-path="../workflow/workflow.html">
-
- <a href="../workflow/workflow.html">
-
-
- 前端工作流配置
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.5" >
-
- <span>
-
-
- 多玩SVN和常用页面
-
- </span>
-
-
- <ul class="articles">
-
-
- <li class="chapter " data-level="1.5.1" data-path="../svn/address.html">
-
- <a href="../svn/address.html">
-
-
- svn及常用地址
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.5.2" data-path="../svn/">
-
- <a href="../svn/">
-
-
- svn目录介绍
-
- </a>
-
-
- </li>
-
- </ul>
-
- </li>
-
- <li class="chapter " data-level="1.6" data-path="./">
-
- <a href="./">
-
-
- 发布器简介
-
- </a>
-
-
- <ul class="articles">
-
-
- <li class="chapter " data-level="1.6.1" data-path="all.html">
-
- <a href="all.html">
-
-
- 发布器调用大全
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.2" >
-
- <span>
-
-
- 实用技巧
-
- </span>
-
-
- <ul class="articles">
-
-
- <li class="chapter " data-level="1.6.2.1" data-path="locate.html">
-
- <a href="locate.html">
-
-
- 定位相关
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.2.2" data-path="quote.html">
-
- <a href="quote.html">
-
-
- 引用模板
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.2.3" data-path="addredss.html">
-
- <a href="addredss.html">
-
-
- 预览地址和正式地址
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.2.4" data-path="flesh.html">
-
- <a href="flesh.html">
-
-
- 刷新模板
-
- </a>
-
-
- </li>
-
- </ul>
-
- </li>
-
- <li class="chapter " data-level="1.6.3" >
-
- <span>
-
-
- 常用语法
-
- </span>
-
-
- <ul class="articles">
-
-
- <li class="chapter active" data-level="1.6.3.1" data-path="alert.html">
-
- <a href="alert.html">
-
-
- 语法核心
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.3.2" data-path="piclist.html">
-
- <a href="piclist.html">
-
-
- 图片列表
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.3.3" data-path="rank.html">
-
- <a href="rank.html">
-
-
- 排行榜
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.3.4" data-path="dwvideo.html">
-
- <a href="dwvideo.html">
-
-
- 多玩视频
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.3.5" data-path="huyavideo.html">
-
- <a href="huyavideo.html">
-
-
- 虎牙视频
-
- </a>
-
-
- </li>
-
- </ul>
-
- </li>
-
- <li class="chapter " data-level="1.6.4" data-path="special.html">
-
- <a href="special.html">
-
-
- 专区嵌套
-
- </a>
-
-
- <ul class="articles">
-
-
- <li class="chapter " data-level="1.6.4.1" data-path="./">
-
- <a href="./">
-
-
- 首页
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.4.2" data-path="tag.html">
-
- <a href="tag.html">
-
-
- 标签和标签图
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.6.4.3" data-path="art.html">
-
- <a href="art.html">
-
-
- 文章页
-
- </a>
-
-
- </li>
-
- </ul>
-
- </li>
-
- </ul>
-
- </li>
-
- <li class="chapter " data-level="1.7" data-path="../duowan/">
-
- <a href="../duowan/">
-
-
- 多玩网
-
- </a>
-
-
- </li>
-
- <li class="chapter " data-level="1.8" data-path="../box/">
-
- <a href="../box/">
-
-
- 盒子
-
- </a>
-
-
- <ul class="articles">
-
-
- <li class="chapter " data-level="1.8.1" data-path="../box/lolbox.html">
-
- <a href="../box/lolbox.html">
-
-
- LOL盒子
-
- </a>
-
-
- </li>
-
- </ul>
-
- </li>
-
- <li class="chapter " data-level="1.9" data-path="../book/README.html">
-
- <span>
-
-
- 文档制作简介
-
- </a>
-
-
- </li>
-
-
- <li class="divider"></li>
- <li>
- <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
- Published with GitBook
- </a>
- </li>
- </ul>
- </nav>
-
-
- </div>
- <div class="book-body">
-
- <div class="body-inner">
-
-
- <div class="book-header" role="navigation">
-
- <!-- Title -->
- <h1>
- <i class="fa fa-circle-o-notch fa-spin"></i>
- <a href=".." >语法核心</a>
- </h1>
- </div>
- <div class="page-wrapper" tabindex="-1" role="main">
- <div class="page-inner">
-
- <div id="book-search-results">
- <div class="search-noresults">
-
- <section class="normal markdown-section">
-
- <h1 id="语法核心">语法核心</h1><h2 id="基本语法">基本语法</h2><pre><code>#set ($list=$data.getPicList("杂谈",60,255,0,10))//调用tag,以及确定好数量,具体语法会在下面有说明
- #foreach($one in $list)//获取每一条tag数据
- 这里写你喜欢调用的东西 例如:
- #set ($title=$one.getString("title"))//标题
- #set ($picurl=$one.getString("picurl"))//图片路径
- #set ($thislink=$data.getRelatedUrl($one.getString("articleid"))) //文章相对路径
- ....
- //填充到结构里面,就是对含有文字描述的结构进行填充
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>li</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$thislink<span class="token punctuation">"</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-vedioList__link<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$picurl<span class="token punctuation">"</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$title<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>em</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-vedioList__tit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>$title<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>em</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>a</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>li</span><span class="token punctuation">></span></span>
- #end //结束循环</code></pre>
- <p><code>完整代码</code></p><pre><code>#set ($list=$data.getPicList("杂谈",60,255,0,10))
- #foreach($one in $list)
- #set ($title=$one.getString("title"))
- #set ($picurl=$one.getString("picurl"))
- #set ($thislink=$data.getRelatedUrl($one.getString("articleid")))
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>li</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$thislink<span class="token punctuation">"</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-vedioList__link<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$picurl<span class="token punctuation">"</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$title<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>em</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-vedioList__tit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>$title<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>em</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>a</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>li</span><span class="token punctuation">></span></span>
- #end</code></pre>
- <p>所以说发布器模板(非最终文章页)最<strong>常用</strong>的语法核心就是<strong>循环调用</strong></p><pre><code>#foreach($one in $list)
- 循环体
- #end</code></pre>
- <blockquote><p>特别值得注意的是, 发布器的语法分析器,会根据<code>#end</code>来判断语法是否结束,所以新手使用发布器语法的时候, 很容易漏掉, 需加倍小心</p></blockquote><h2 id="跨专区调用">跨专区调用</h2><p>本专区调用</p><pre><code>$data.getPicList(...)
- $data.getList(...)</code></pre>
- <p>跨专区调用</p><pre><code>$data.getPicListOther(频道id/频道中文名,...)
- $data.getListOther(频道id/频道中文名,...)</code></pre>
- <p>特别需要注意的是,跨专区调用的时候,读取的新闻列表地址,不能用相对地址,要用绝对地址</p><pre><code>相对地址
- #set ($thislink=$data.getRelatedUrl($articleid))
- 绝对地址
- #set ($reallink=$data.getUrl($channelid,$articleid))</code></pre>
- <p><code>跨专区调用完整例子</code></p><pre><code>#set ($list=$data.getPicListOther("首页","试玩解说",60,255,4))
- #set ($channel='首页')
- #foreach($one in $list)
- #set ($reallink=$data.getUrl($channel,$one.getString("articleid")))
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>li</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>$reallink<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>a</span><span class="token punctuation">></span></span>
- <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>li</span><span class="token punctuation">></span></span>
- #end</code></pre>
- <h2 id="判断语句">判断语句</h2><pre><code>#if(...)
- ...
- #elseif
- ...
- #end
- </code></pre>
- <p>同样需要注意的也是不要忘记写<code>#end</code>, <strong>一个if就对应一个end</strong></p>
-
- </section>
-
- </div>
- <div class="search-results">
- <div class="has-results">
-
- <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
- <ul class="search-results-list"></ul>
-
- </div>
- <div class="no-results">
-
- <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
-
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </div>
-
-
-
- <a href="piclist.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 图片列表">
- <i class="fa fa-angle-right"></i>
- </a>
-
-
-
- </div>
- <script>
- var gitbook = gitbook || [];
- gitbook.push(function() {
- gitbook.page.hasChanged({"page":{"title":"语法核心","level":"1.6.3.1","depth":3,"next":{"title":"图片列表","level":"1.6.3.2","depth":3,"path":"cms/piclist.md","ref":"cms/piclist.md","articles":[]},"previous":{"title":"常用语法","level":"1.6.3","depth":2,"ref":"","articles":[{"title":"语法核心","level":"1.6.3.1","depth":3,"path":"cms/alert.md","ref":"cms/alert.md","articles":[]},{"title":"图片列表","level":"1.6.3.2","depth":3,"path":"cms/piclist.md","ref":"cms/piclist.md","articles":[]},{"title":"排行榜","level":"1.6.3.3","depth":3,"path":"cms/rank.md","ref":"cms/rank.md","articles":[]},{"title":"多玩视频","level":"1.6.3.4","depth":3,"path":"cms/dwvideo.md","ref":"cms/dwvideo.md","articles":[]},{"title":"虎牙视频","level":"1.6.3.5","depth":3,"path":"cms/huyavideo.md","ref":"cms/huyavideo.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["prism","-highlight"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"prism":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":[]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"level_number":true,"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"links":{"sharing":{"all":false,"google":false,"facebook":false,"twitter":false,"weibo":false}},"gitbook":"3.2.0"},"file":{"path":"cms/alert.md","mtime":"2016-11-24T06:09:45.000Z","type":"markdown"},"gitbook":{"version":"3.2.0","time":"2018-03-19T02:13:33.701Z"},"basePath":"..","book":{"language":""}});
- });
- </script>
- </div>
-
- <script src="../gitbook/gitbook.js"></script>
- <script src="../gitbook/theme.js"></script>
-
-
- <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
-
-
-
- <script src="../gitbook/gitbook-plugin-search/search.js"></script>
-
-
-
- <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
-
-
-
- <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
-
-
-
- <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
-
-
-
- <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
-
-
- </body>
- </html>
|