如何仅对某些项目在 TMENU 中应用不同的包装? [英] How to apply a different wrap in a TMENU for certain items only?

查看:27
本文介绍了如何仅对某些项目在 TMENU 中应用不同的包装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 TMENU 中,我只想对某些页面应用特殊换行.

In a TMENU, I would like to apply a special wrap to certain pages only.

所以

Home
-- This
-- That
-- Such
-----A
-----Thing

只有页面Such"才会有这个包装(带有一个特殊的类或 wrapItemsAndSub 的图标).

Only the page "Such" would have this wrap (with a special class or an icon for wrapItemsAndSub).

理想情况下,这可以从页面树/从 CMS 中完成.或者通过pid.但我认为不可能以简单的方式进入 TMENU?OptionSplit 不是一个选项,因为它只是几个特殊页面.

Ideally, this could be done from the page tree / from the CMS. Or by pid. But I think it's not possible to reach into the TMENU in an easy way? OptionSplit is not an option, as it's only a few special pages.

这能做到吗?如何做到?

Can this be done and how?

推荐答案

顺便说一句:正如 pgampe 所说,当你选择类名时,它当然可以通过一些复选框甚至下拉菜单来实现更通用.

BTW: as pgampe said it can be of course done more universal with some checkbox or even dropdown when you select class name.

这是一个关于复选框的简短教程.对于本教程,我假设扩展名是t3_local"

This is a short tutorial for checkbox. For this tutorial I assume the extension name is "t3_local"

第一步

在 ext_tables.sql 文件中添加:

In ext_tables.sql file add:

CREATE TABLE pages (
    tx_t3local_special tinyint(4) DEFAULT '0' NOT NULL,
}

然后进入扩展管理器进入您的扩展并更新数据库以在页面表中创建新字段.

Then go into Extension Manager into your extension and update database to create the new field in pages table.

第 2 步

在 ext_tables.php 文件中添加:

In ext_tables.php file add:

$tempColumns = Array(
    'tx_t3local_special' => Array(
        'exclude' => 1,
        'label' => 'Some label for special',
        'config' => Array(
            'type' => 'check',
            'default' => 0
        )
    )

);

t3lib_div::loadTCA('pages');
t3lib_extMgm::addTCAcolumns('pages', $tempColumns, 1);
t3lib_extMgm::addToAllTCAtypes('pages', 'tx_t3local_special');

现在可以在后端使用了.清除 TYPO3 缓存后,您应该会看到页面属性中的复选框.现在我们只能使用它在前端构建我们的菜单.

It is ready now to use in the backend. After you clear the TYPO3 cache you should see the checkbox in page properties. Now we must only use it to build our menu in frontend.

第 3 步

现在这一切都取决于你想用这个开关做什么.假设你想为 li 添加一个类,这里​​有一个小技巧,如何允许使用多个这样的开关来累积不同的类.

Now it all depends what do you want to do with this switch. Assuming that you want to add a class for li here is a little trick how to allow to use several such switches to accumulate different classes.

NO.wrapItemAndSub.stdWrap {
   prepend.cObject = LOAD_REGISTER
   prepend.cObject {

     special1class.cObject = TEXT
     special1class.cObject {
        value = special1-class
        if.isTrue.field = tx_t3local_special
      }
     special2class.cObject = TEXT
     special2class.cObject {
        value = special2-class
        if.isTrue.field = tx_t3local_special2
      }

   }
   append = TEXT
   append.value = <li class="clearfix {register:special1class} {register:special2class}">/li>
   append.insertData = 1
}

注意

正如您现在知道如何向页面属性添加开关一样,您还可以使用它们来关闭/打开页面上的某些功能.例如,我使用这样的开关来打开/关闭页面的面包屑.在这个例子中,如果复选框被选中关闭面包屑.

As you now know how to add switches to page property you can also use them to turn off/on some functionality on page. For example I use such switch to turn on/off breadcrumbs for page. In this example the if checkbox is checked the breadcrumb of off.

对于这项工作,您必须记住将字段名称添加到typo3conf/localconf.php 文件(或6.x 中的LocalConfiguration.php)

For this working you must remember to add the field name to typo3conf/localconf.php file (or LocalConfiguration.php in 6.x)

$TYPO3_CONF_VARS['FE']['addRootLineFields'] .= ',tx_t3local_breadcrumb';

和 TS:

lib.breadcrumb = COA
lib.breadcrumb.stdWrap.if.isFalse.data = page:tx_t3local_breadcrumb
lib.breadcrumb {
...
...
...
}

这篇关于如何仅对某些项目在 TMENU 中应用不同的包装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆