Gallery:如何移除根目录相册(Root Album)链接

来自站长百科
跳转至: 导航、​ 搜索

重要:仅相册管理员可进行此操作,因为需要在核心模板"BreadCrumb.tpl"中做修改!

这里给出详细步骤说明移除根目录相册链接的办法。如果你希望访问者被限制于某用户相册之内进行浏览的话,移除根目录相册链接是一个好主意。

详细步骤:

1. 首先在"gallery2/modules/core/templates/blocks/"下新建一个"local"子目录

2. 将BreadCrumb.tpl复制到该新建的子目录中

3. 按以下方法修改local/BreadCrumb.tpl:

{*
 * $Revision: 1.4 $
 * 如果你要对此文件进行自定义,不要直接对其进行编辑,因为将来的更新操作
 * 会将其覆盖掉的。将其复制到新的"local"目录下并对该拷贝进行
 * 编辑。Gallery会首先查看该文件并在存在的情况下首先应用它。
 *}
{*
 * 查看各breadcrumb并将其显示为链接。
 *
 * G2使用highlight id来明了当你跟随breadcrumb返回相册树时该
 * 拉取哪个页面。请勿将最后一个项目作为链接。
 *}
<div class="{$class}">
  {section name=parent loop=$theme.parents}
  
  {if !$smarty.section.parent.last}
	{if !$smarty.section.parent.first}
  		

		<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
			   arg3="highlightId=`$theme.parents[parent.index_next].id`"}"
	     class="BreadCrumb-{counter name="BreadCrumb"}">
	    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
	    {if isset($separator)} {$separator} {/if}
	{else}
             {* further in sub-album tree*}
	{/if}
  {else}
  	{if $smarty.section.parent.first}
		{* first sub-album*}
	{else}
	  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
			   arg3="highlightId=`$theme.item.id`"}"
	     class="BreadCrumb-{counter name="BreadCrumb"}">
	    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
	    {if isset($separator)} {$separator} {/if}
  	{/if}
  {/if}
	  {/section}

	  {if ($theme.pageType == 'admin' || $theme.pageType == 'module')}
	  <a href="{g->url arg1="view=core.ShowItem"
			   arg2="itemId=`$theme.item.id`"}" class="BreadCrumb-{counter name="BreadCrumb"}">
	     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</a>
	  {else}
		<span class="BreadCrumb-{counter name="BreadCrumb"}">
		{$theme.item.title|default:$theme.item.pathComponent|markup:strip}</span>
	  {/if}
</div>