Arlicle

ArlicleTag 整站标签

ArlicleTag一个类,是用来获取一些网站基本信息的标签,如: 网站标题, 网站描述, 网站网址等的信息.

获取方法smart_title()

smart_title() 是一个智能获取网站标题的方法, 它会根据当前所在页面自动的调取出合理的标题.以符合人类的阅读和搜索引擎的优化,以下是调取的几种情况:

  • 当访问页面为首页时, 网站标题为: "网站名称" (该名称为Arlicle后台设置)
  • 当访问页面为一个单页面或者列表页面时, 网站标题变为: "页面名称(或分类名称) - 网站名称"
  • 当访问页面为一个新闻页面时, 网站标题为: "新闻标题 - 分类名称 - 网站名称"

例子:

<?php echo ArlicleTag::smart_title(); ?>site_title()

site_title() 是用来获取网站的名称, 该名称是由 Arlicle后台 -> 选项 -> 选项设置 -> 网站名称 进行修改.

例子:

<?php echo ArlicleTag::site_title(); ?>site_description()

site_description() 是用来获取网站描述, 该项由 Arlicle后台 -> 选项 -> 选项设置 -> 网站描述 进行修改,

例子:

<?php echo ArlicleTag::site_description(); ?>site_url()

site_url() 是用来获取网站的网址, 该项由 Arlicle后台 -> 选项 -> 选项设置 -> 首页网址 进行修改.

例子:

<?php echo ArlicleTag::site_url(); ?>PageTag 页面标签

PageTag一个类,是用来获取单独页面信息的标签,如: 页面名称, 页面内容, 页面的自定义字段等信息.

获取方法is_page()

is_page() 是用来判断当前访问的是不是一个页面,它有一个参数,设置为:

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动判断当前页是否为一个页面
  • 当设置了参数中的uri时,将判断指定uri的页面是否为一个页面

例子:

<?phpif (PageTag::is_page()) { // 将判断当前的访问是不是一个页面 echo '当前是一个页面';}?><?phpif (PageTag::is_page(array('uri'=>'docs'))) { // 判断指定uri为docs的是否是一个页面 echo '访问网址为docs的是一个页面';}?>id()

id() 是用来获取页面的id, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的id
  • 当设置了参数中的uri时,将判断指定uri的页面id, 如果指定的uri不是页面,将返回0.

例子:

<?phpecho PageTag::id(); // 打印当前页的idecho PageTag::id(array('uri'=>'docs')); // 打印指定uri页面的id?>title()

title() 是用来获取页面的标题, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的标题
  • 当设置了参数中的uri时,将判断指定uri的页面标题, 如果指定的uri不是页面,将返回空.

例子:

<?phpecho PageTag::title(); // 打印当前页的标题echo PageTag::title(array('uri'=>'docs')); // 打印指定uri页面的标题?>content()

content() 是用来获取页面的内容, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的内容
  • 当设置了参数中的uri时,将判断指定uri的页面内容, 如果指定的uri不是页面,将返回空.

例子:

<?phpecho PageTag::content(); // 打印当前页的内容echo PageTag::content(array('uri'=>'docs')); // 打印指定uri页面的内容?>order()

order() 是用来获取页面的显示顺序, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的显示顺序
  • 当设置了参数中的uri时,将判断指定uri的页面显示顺序, 如果指定的uri不是页面,将返回空.

例子:

<?phpecho PageTag::order(); // 打印当前页的显示顺序echo PageTag::order(array('uri'=>'docs')); // 打印指定uri页面的显示顺序?>uri()

uri() 是用来获取当前页面的uri访问网址

例子:

<?phpecho PageTag::uri(); // 打印当前页的访问网址?>template()

template() 是用来获取页面的模板名称, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的模板名称
  • 当设置了参数中的uri时,将判断指定uri的页面模板, 如果指定的uri不是页面,将返回空.

例子:

<?phpecho PageTag::template(); // 打印当前页的模板echo PageTag::template(array('uri'=>'docs')); // 打印指定uri页面的模板?>parent_id()

parent_id() 是用来获取页面的父类id, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的父类id
  • 当设置了参数中的uri时,将判断指定uri页面的父类id, 如果指定的uri不是页面,将返回空.

例子:

<?phpecho PageTag::parent_id(); // 打印当前页的父类idecho PageTag::parent_id(array('uri'=>'docs')); // 打印指定uri页面的父类id?>page()

page() 是用来获取页面对象,有了该对象,就可以获取你所想要的page对象的信息, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的对象
  • 当设置了参数中的uri时,将判断指定uri的页面对象, 如果指定的uri不是页面,将返回空的对象.

例子:

<?php$page = PageTag::page(); // 获取当前页面对象echo PageTag::page()->id; //打印当前页面的idecho PageTag::page()->title; //打印当前页面的标题echo PageTag::page()->content; //打印当前页面的内容echo PageTag::page()->parent_id; //打印当前页面的父类idecho PageTag::content(array('uri'=>'docs')); // 打印指定uri页面的内容?>parent()

parent() 是用来获取页面的父类对象, 它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);

  • 当参数为空时, 将自动获取当前页面的父类对象
  • 当设置了参数中的uri时,将判断指定uri页面的父类对象, 如果指定的uri不是页面,将返回空对象.
  • 如果当前页面没有父类, 也将返回空对象

例子:

<?phpecho PageTag::parent()->id; // 打印当前页的父类idecho PageTag::parent()->title // 打印当前页的父类标题echo PageTag::parent()->content //打印当前页面的父类内容echo PageTag::parent()->uri // 打印当前页面的父类网址echo PageTag::parent()->type // 打印当前页面的父类的类型echo PageTag::parent(array('uri'=>'docs'))->id; // 打印指定uri页面的父类idecho PageTag::parent(array('uri'=>'docs'))->title // 打印指定uri页的父类标题echo PageTag::parent(array('uri'=>'docs'))->content //打印指定uri页面的父类内容echo PageTag::parent(array('uri'=>'docs'))->uri // 打印指定uri页面的父类网址echo PageTag::parent(array('uri'=>'docs'))->type // 打印指定uri页面的父类的类型?>children()

children() 是用来获取页面的子类对象, 返回的结果为一个数组,它有一个参数,设置为.

array( 'uri'=>'' // uri为一个字符串, 为网站架构图的访问网址);
  • 当参数为空时, 将自动获取当前页面的子类
  • 当设置了参数中的uri时,将判断指定uri页面的子类, 如果指定的uri不是页面,将返回空数组.
  • 如果当前页面没有子类,也将返回空数组

例子:

<?php$children = PageTag::children(); //获取当前页的子类foreach($children as $child) { echo $child->title,'<br>'; //打印子类的标题}$children = PageTag::children(array('uri'=>'docs')); //获取指定uri页面的子类foreach($children as $child) { echo $child->title,'<br>'; //打印子类的标题}?>自定义字段

在Arlicle后台 -> 管理 -> 网站架构图管理 中, 添加一个页面时,根据需要,我们会创建不同的自定义字段. 然后我们在编辑页面时,进行对应页面自定义字段内容的填充,最后, 我们就需要通过方法将这些自定义字段的内容获取出来.

获取的方法很简单, 和页面对象自身的元素一样,直接使用页面对象获取,获取的key为自定义字段的标签, 如果该自定义字段标签不存在, 将输出为空

例子:

<?phpecho PageTag::page()->my_name; // 获取当前页面标签为 my_name 的内容echo PageTag::page()->customtag // 获取当前页面标签为customtag 的内容echo PageTag::page(array('uri'=>'index'))->my_name; //获取指定uri页面标签为 my_name 的内容echo PageTag::page(array('uri'=>'index'))->customtag // 获取指定uri页面标签为 customtag 的内容?>DiagramTag 网站架构图标签

DiagramTag一个网站架构图类,是用来获取一些网站架构图信息的标签,如: 主菜单, 子菜单, 当前位置等的信息.

获取方法diagram()

diagram() 是用来获取网站网站架构图对象, 它包含一个参数,该参数默认为空的array(),设置为:

array( 'uri' => '' // uri为一个字符串, 为网站架构图的访问网址).
  • 当参数为空时自动获取当前访问的diagram对象
  • 当设置了参数,择获取参数uri指定的diagram对象

例子:

<?phpecho DiagramTag::diagram()->title; //打印当前访问页面的标题echo DiagramTag::diagram()->uri; //打印当前访问页面的访问网址echo DiagramTag::diagram()->type; //打印当前访问页面的类型echo DiagramTag::diagram()->id // 打印当前访问页面的idecho DiagramTag::diagram()->content // 打印当前访问页面的内容$parent = DiagramTag::diagram()->parent; //获取当前访问页面的父类,为一个对象, 属性和diagram一样$children = DiagramTag::diagram()->children //获取当前访问页面的子类, 为一个数组, 每个child的属性和diagram一样?>position_as_span()

position_as_span()方法获取得到当前访问所在的位置, 返回结果为一个字符串, 包含有一个参数, 设置为:

array( 'uri' => '', // uri为一个字符串, 为网站架构图的访问网址 'space' =>' > ' , // 为当前位置之间的间隔符号, 默认为 " > ", 'home' => false // 为是否在首页显示, 默认为false, 不在首页显示)

例子:

<?phpecho DiagramTag::position_as_span(); // 打印出会在首页也显示位置的 当前位置?>

将输出:

<span id="position" class="position"> <a href="/index.php/">首页</a> > <a href="/index.php/about">关于我们</a> > <a href="/index.php/about">公司简介</a></span>

例子2

<?phpecho DiagramTag::position_as_span(array('space'=>' » ')); // 打印会在首页也显示位置的当前位置, 用' » '来分隔?>

将输出:

<span id="position" class="position"> <a href="/index.php/">首页</a> » <a href="/index.php/about">关于我们</a> » <a href="/index.php/about">公司简介</a></span>
mainmenu_as_ul()

mainmenu_as_ul()方法将输出网站的主菜单,输出为一个字符串, 包含一个参数,设置为:

array( ' ul_class' => '', // 设置菜单的ul的class样式, 默认为空 'li_class' => '', // 设置菜单的li样式, 默认为空 'li_selected_class' => 'selected', // 设置菜单的li为当前菜单的状态, 默认为selected 'a_class' => '', // 设置菜单中a的class样式, 默认为空 'a_selected_class' => '' // 设置菜单中a的选中时的样式)

例子1: 使用默认的设置输出主菜单

<?phpecho DiagramTag::mainmenu_as_ul(); // 打印主菜单,?>

将输出

<ul> <li id="mainmenu_1" class="selected"><a href="/">首页</a></li> <li id="mainmenu_2"><a href="/about">关于我们</a></li> <li id="mainmenu_3"><a href="/contact">联系我们</a></li></ul>

例子2: 设置li选中状态和a的选中状态

<?phpecho DiagramTag::mainmenu_as_ul(array('li_selected_class'=>'current', 'a_selected_class'=>'current_a')); // 设置主菜单的li选中样式为current, a的选中样式为current_a?>

将输出

<ul> <li id="mainmenu_1" class="current"><a href="/" class="current_a">首页</a></li> <li id="mainmenu_2"><a href="/about">关于我们</a></li> <li id="mainmenu_3"><a href="/contact">联系我们</a></li></ul>

例子3:设置li的样式和a的样式

<?phpecho DiagramTag::mainmenu_as_ul(array('li_class'=>'my_li_class', 'a_class'=>'my_a_class')); // 设置主菜单的li样式为my_li_class, a的样式为my_a_class?>

将输出:

<ul> <li id="mainmenu_1" class="selected"><a href="/">首页</a></li> <li id="mainmenu_2" class="my_li_class"><a href="/about" class="my_a_class">关于我们</a></li> <li id="mainmenu_3" class="my_li_class"><a href="/contact" class="my_a_class">联系我们</a></li></ul>mainmenu()

mainmenu() 方法将获取到网站架构图根目录的菜单,返回的结果是一个数组,

例子:

<?phpforeach(DiagramTag::mainmenu() as $mainmenu) { echo $mainmenu->title; // 打印菜单标题 echo $mainmenu->uri // 打印菜单网址?>root()

root() 是用来获取网站架构图的根菜单对象, 返回一个diagram对象.包含一个参数,设置如下.

array( 'uri' => '' // uri为一个字符串, 为网站架构图的访问网址)
  • 当uri为空时,自动获取当前访问的uri的根菜单
  • 当指定uri时, 获取指定uri的根菜单

例子:

<?phpecho DiagramTag::root()->id; // 打印当前网站架构图的根对象的idecho DiagramTag::root()->title; //打印当前网站架构图的根对象的标题echo DiagramTag::root()->uri; // 打印当前网站架构图的根对象的uri访问网址echo DiagramTag::root()->type; // 打印当前网站架构图的根对象的类型echo DiagramTag::root(array('uri'=>'download/plugins'))->id; // 打印指定网站架构图的根对象的idecho DiagramTag::root(array('uri'=>'download/plugins'))->title; //打印指定网站架构图的根对象的标题echo DiagramTag::root(array('uri'=>'download/plugins'))->uri; // 打印指定网站架构图的根对象的uri访问网址echo DiagramTag::root(array('uri'=>'download/plugins'))->type; // 打印指定网站架构图的根对象的类型?>submenu_as_ul()

submenu_as_ul() 用来获取网站架构图的子菜单, 输出为子菜单的字符串.包含一个参数, 设置为:

array( 'ul_class' => '', // ul样式,默认为空 'li_class' => '', // li样式,默认为空 'li_selected_class' => 'selected', // li 选中样式,默认为 selected 'a_class' => '', // a的样式, 默认为为空 'a_selected_class' => '', // a选中样式, 默认为空 'uri' => '' // 指定要获取的diagram, 默认为空, 自动获取当前访问的diagram 'start_level'=>0 //设定要从第几级开始获取子菜单)

例子1:

<?phpecho DiagramTag::submenu_as_ul(); // 将输出当前页面的子菜单列表?>例子2:<?phpecho DiagramTag::submenu_as_ul(array('a_selected_class'=>'current_a')); // 指定a样式的子菜单?>submenu()

submenu() 用来获取子菜单列表,返回一个数组, 有一个参数, 设置为:

array( 'uri' => '' // 网站架构图的访问网站, 默认为空).
  • 当uri为空时,自动获取当前访问的子菜单列表
  • 当指定uri时,获取指定uri的diagram对象的子菜单

例子:

<?php$submenus = DiagramTag::submenu();foreach($submenus as $submenu) { echo $submenu->title; //打印子菜单标题 echo $submenu->uri //打印子菜单网址}?>trace()

trace()用来获取当前用户访问网站的轨迹, 返回为一个数组

例子:

<?phpforeach(DiagramTag::trace() as $item) { echo $item->title; //打印访问页面的标题 echo $tiem->uri; //打印访问页面的网址 echo $tiem->type; //打印访问页面的类型}?> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值