J5_04产品新闻列表页

weeya4个月前JTBC教程52

1、头尾模板调用代码
{$=$take('global.communal.header')}
{$=$take('global.communal.footer')}

1、模块名称{$=$take('index.title', 'lng')}
2、当前分类的id:{$=intval($req -> get('category'))}
3、调用分类列表
{$=$render('global.render.product-list', $fetch(['genre' => 'universal/category', 'where' => ['genre' => 'product', 'father_id' => 0]]))}

4、调用分类列表,节点模板文件在当前模块index.jtbc里面
{$=$render('index.category', $fetch(['genre' => 'universal/category', 'where' => ['genre' => '{$>this.genre}', 'father_id' => 0]]))}

5、文章列表图片url地址
{@}
<img src="{$=$htmlEncode($getValueFromJSON(#image, 'fileurl'))}" class="idxPro_img" alt="{$title}" />
<a href="./?type=detail&amp;id={$id}">
    {$title}
</a>
{@}

6、调用无分类id文章列表
{$=$render('global.render.home-news-list', $fetch(['genre' => 'news', 'limit' => 6]))}

7、调用有分类id文章列表
{$=$render('global.render.home-news-list', $fetch(['genre' => 'news', 'where' => ['category' => 2],  'limit' => 3]))}

8、调用推荐的文章,有recommend字段
{$=$render('global.render.about-news-a2', $fetch(['genre' => 'about/news', 'limit' => 5, 'where' => ['recommend' => 1]]))}

9、调用联系方式节点模板内容{$=$take('global.render.contactus')}

10、调用附件的第一条图片(新闻动态图片)
{$=$htmlEncode($getValueFromJSON(#attachment, '0->filepath'))}
{$=$htmlEncode($getValueFromJSON(#attachment, '1->filename'))}第2条附件地址

11、时间
{$=$formatDate(#time, 1)} 年月日 2022-9-22
{$=$formatDate(#time, 2)} 年月日 2022.9.22
{$=$formatDate(#time, -1)}-{$=$formatDate(#time, -2)} 年月2022-9
{$=$formatDate(#time, -3)} 日22

12、截取内容字段100字{$=$htmlEncode(mb_substr(strip_tags(#content), 0, 100))}
      截取标题字段15个字{$=$htmlEncode(mb_substr(#title, 0, 15))}
                       {$=$htmlEncode(#title, 2)}

13、分类页面 显示分类名称
在\universal\common\template\render.jtbc 新建节点categorytitle
{$title}
列表模板调用
{$=$render('universal:render.categorytitle', $fetch(['genre' => 'universal/category', 'where' => ['genre' => '{$>this.genre}', 'id' => intval($req -> get('category')) ]]))}

14、列表页调用文章所属分类名称
思路是调用文章列表,然后调用节点调用分类的调用代码如下:列表页直接调用也可以。
{$=$render('global.render.categorytitle', $fetch(['genre' => 'universal/category', 'where' => ['genre' => 'product', 'id' => {$category} ]]))}
文章所属分类链接../product/?type=list&category={$category}

分类页面图片
在\universal\common\template\render.jtbc 新建categoryimage节点
{$=$htmlEncode($getValueFromJSON(#image, 'fileurl'))}
前端模板
<img src="{$=$render('global.render.categoryimage', $fetch(['genre' => 'universal/category', 'where' => ['genre' => '{$>this.genre}', 'id' => intval($req -> get('category'))]]))}" />

<jtbc-pagination current-page="{$[pagenum]}" total-page="{$[pagecount]}" url="./?{$=$htmlEncode($request_query_rebuild(['page' => '__page__']))}"></jtbc-pagination>分页
分页模板目录地址
/Public/universal/common/template/render.jtbc文件
修改pagination节点

分类图片打开/public/product/common/category.jtbc
    <item>
      <name><![CDATA[has_image]]></name>
      <zh-cn><![CDATA[false]]></zh-cn>
    </item>
打开分类图片功能,false改成true

调用分类下的文章列表
{$=$render('global.render.product-list-div', $fetch(['genre' => 'product', 'where' => ['category' => {$id}],  'limit' => 10]))}
product-list-div节点代码
<div>
    {@}
    <a href="product/?type=detail&amp;id={$id}">
        {$title}
    </a>
    {@}
</div>

增加产品模块首页
1、程序增加
/public/product/common/diplomat/index.php文件
参考list节点增加一个default节点,
2、/public/product/common/diplomat/index.php文件,最后一行设置默认首页。
$this -> list($req, $res);
改成
$this -> default($req, $res);
3、模板增加
/public/product/common/template/index.jtbc文件
增加default模板节点。

截取新闻内容字段100字调用代码怎么写?
使用php的字符截取函数即可,全部函数在模板里均可以直接使用
{$=$htmlEncode(mb_substr(#你的字段名, 0, 100))}
{$=$htmlEncode(mb_substr(strip_tags(#content), 0, 100))}截取内容100字

相关文章

J5_09搜索

    需要在可以被搜索的模块目录中手动添加common/search.jtbc引导文件来激活搜索功能    需要手动构建关键字输入框并通过...

J5增加tag标签自定义URL

1、index.php文件detail节点$rsTag = strval($rs -> tag);//增加tag模块管理-添加字段tag,16标签输入框。2、tag/矿山副井井筒装备安装/htt...

J5模块首页-列表分类-文章页面自定义TDK

J5模块首页-列表分类-文章页面自定义TDK方法1、模块添加字段,后台开发维护》模块管理》右边的设置,在模块设置界面,点击右上角添加新字段按钮添加3个字段,用来存储自定义的TDK数据seotitle,...

J5_10多语言

多语言/Public/console/common/language/sel_lang.jtbc增加节点不同语言不同模板Public/common/diplomat/index.php修改return...

J5_01安装相关

JTBC5.0笔记jtbc模板里只要理解3个东西就完事儿了1个叫 $take1个叫 $render另外1个叫 $fetch/Config/DB/MySQL.php,数据库链接~~~~~~~~~~~~~...

J5伪静态

Public/news/.rewrite的地址重写配置:<?phpreturn [  [    'file' => 'ind...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。