1

リンクなしで属性にURLを含むメニューを作成する必要があります。
URL は data-href="|" にある必要があります しかし、今はタイトルだけが属性に印刷されます。
リンクではなく URL のみを返す方法はありますか。すなわち。の代わりにhttp://example.com

または、別の解決策を知っている人はいますか?

lib.mainMenu = HMENU
lib.mainMenu {
    entryLevel = 1
    wrap = <ul id="dropDownMenu">|</ul>

    1 = TMENU
    1 {
        noBlur = 1
        expAll = 1

        NO = 1
        NO {
            wrapItemAndSub = <li class="nochildren">|</li>
            stdWrap2.wrap = <span>|</span>
        }

        ACT < .NO
        ACT.wrapItemAndSub = <li class="active nochildren">|</li>

        # if has children
        IFSUB < .NO
        IFSUB.wrapItemAndSub = <li class="haschildren">|</li>
        IFSUB.allWrap = |

        # if has children and is active
        ACTIFSUB < .IFSUB
        ACTIFSUB.wrapItemAndSub = <li class="active haschildren">|</li>
        ACTIFSUB.allWrap = |
    }

    2 < .1    
    2 {
        wrap = <ul id="subMenu">|</ul>
        NO.ATagParams = rel="nofollow"
        NO.stdWrap2.insertData = 1
        NO.stdWrap2.wrap = <span data-href="|" class="link">{field:title}</span>
        NO.doNotLinkIt = 1

        IFSUB < .NO
        ACTIFSUB < .IFSUB
    }

    3 < .2
}
4

2 に答える 2

1

上記の答えは、マウントポイントがない場合にのみ機能します。ページ ツリーにマウントポイントがあるとすぐに、これらのリンクは正しく生成されません。

マウントポイントを使用している場合でも、HMENU が周囲の a-Tag とページ タイトルのないプレーンな URL を出力するように強制するには、HMENU の IProcFunc プロパティを定義する必要があります。

a-Tags を削除し、ページ タイトルをリンクの URL に置き換える IProcFunc を介して呼び出すことができる小さなメソッドを作成しました。

<?php

class UserFuncUtils {

    /**
     * Modifies sitemap links. Whith this modification, a menu will only generate a plain url instead of an <a>-Tag
     *
     * This is an IProcFunc for a HMENU. The only parameter supplied by this method call is $this->I from the
     * Menu ContentObject. The function call expects a modified $I array to be returned.
     */
    function IProcFunc_plainURL($I) {
        // Show what $I has to offer
        // print \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($I, NULL, 8, FALSE, FALSE, FALSE, array(), array());

        // Remove opening and closing tags and replace title with href attribute. This results in a plain URL being rendered by the menu
        $I['parts']['ATag_begin'] = '';
        $I['parts']['ATag_end'] = '';
        $I['parts']['title'] = $I['linkHREF']['HREF'];

        return $I;
    }
}

?>

この小さなクラスをどこかに保存するだけです (例: /fileadmin/libs/class.userFuncUtils.php)。

includeLibs.userFuncUtils = fileadmin/libs/class.userFuncUtils.php

次に、HMENU の IProcFunc プロパティを設定して、このユーザー関数を指すようにします。

lib.mainMenu = HMENU
lib.mainMenu.IProcFunc = UserFuncUtils->IProcFunc_plainURL

これでうまくいくはずです。

于 2013-12-03T14:06:48.920 に答える