English 中文(简体)
我如何为SDL Tridion的不同页面创建导航菜单?
原标题:How do I create a navigation menu for different pages in SDL Tridion?

我为所有这些类别创建了不同的页面:书籍、移动、计算等。 现在我想在所有页面中设置这种类型的导航菜单(如图所示),打开一个页面应该突出相应的菜单链接。

难道我应该建立一个包含文本和链接的体系,使它具有多重价值吗?所以我应该创建一个构件,最终在所有网页上都形成一个构件?

如果不愿意,请建议采取任何其他更好的办法。

""https://i.sstatic.net/jvCkM.gif" alt="在这里输入图像描述"/ >

最佳回答

如果您使用 ASPX 作为页面类型, 下面描述其他导航逻辑 :

  1. 创建一个包含重要页面信息( ID、 路径、 标题...) 的导航 xml( 包含所有页面)

  2. 创建将生成面包屑或任何其他导航的 ascx 控件。 作为参数控件, 参数控件应检索当前页面 ID

  3. Change page DWT (placing ascx control)

这样您就可以缩短时间( 出版), 导航将会在页面加载时完成 。 不幸的是, 您会以这种方式增加页面加载时间 。 这取决于您需要什么更合适的解决方案 。 更新导航 XML 是这个方法的问题之一 。

问题回答

生成三重星中任何导航的最常用方式就是简单地在基于结构组和页面的 C# 模板中生成。

例如,在模板中(要么是C#碎片,要么是执行 Itemplate 的分类),很容易产生面包屑线索,其方式如下:

var pageDocument = package.GetByType(ContentType.Page).GetAsXmlDocument();
var current = new Page(pageDocument.DocumentElement, engine.GetSession());
var breadcrumb = page.Title;
while (current.OrganizationalItem != null)
{
    current = current.OrganizationalItem;
    breadcrumb = current.Title + " > " + breadcrumb;
}
package.PushItem("breadcrumb", 
                 package.CreateStringItem(ContentType.Text, breadcrumb));

上述碎片实际上只显示如何向上浏览结构组的层次。 您仍然需要将每个结构组作为链接, 也许通过查看每个 < code> PublishUrl 属性的 < code> Structure Group , 来将每个结构组设置为链接 。

我知道你不是在问面包屑线索,你看起来更像左键。但所有导航元素的处理方法相似:用托姆.NET在您的外板上绕过相关的页面和结构组,并从中生成您的导航 HTML。

要获得当前结构组中所有页面的列表( 并标记当前结构组), 我希望有类似的东西 :

var pageDocument = package.GetByType(ContentType.Page).GetAsXmlDocument();
var current = new Page(pageDocument.DocumentElement, engine.GetSession());
var sg = (StructureGroup) page.OrganizationalItem;
string result = "<ul>";
foreach (var page in sg.GetItems())
{
    result += (page.Id != current.Id) ? "<li>" : "<li class= selected >";
    result += page.Title;
    result += "</li>";
}
result += "</ul>";
package.PushItem("siblings", package.CreateHtmlItem(result));

也请参看>这个来自Nick的伟大例子,他在其中生成了一个完整的网站映射 。这更接近于你最终需要的东西,但当然是一个更多的代码(在这里无法复制太多)。Albert还分享了一些的代码,http://www.albertteboekhorst.com/tridion_how_to/sdl-tridion-sitemapnavigation-rendering-1s/"rel=“nreferr”在使用这一方法方面的经验,并提到替代方法





相关问题
Getting URL of published element in SDL Tridion

Is there any way of finding the absolute URL for a published object in the SDL Tridion Interface? For example when I published a page, how can I find the url where to access the page?

What is C# sample code for VBScript SetLocale Function

I have got below code in VBScript. Sub SetPageLocale() Dim Locale Dim ContextObject Set ContextObject=getContextObject Locale=getFieldValue(ContextObject.Publication.MetadataFields("...

Getting error while using TCMUploadAssembly.exe

Can you please suggest why I am getting below error, when I am trying to upload my Assembly using TCMUploadAssembly.exe, below is the setting which I have done in my POST Build event. $(ProjectDir)...

Component Links not working in 64 bit mode

Brief Summary: We are using Tridion 2009 SP1, however we never used .NET templating, we are still using R5 concept i.e. (VBScript, XSLT etc), we are using broker database for our linking etc. Our ...

热门标签