1. Nainstalovat a povolit n3t Fields
2. V rootu šablony vytvořit složku "n3tfields"
3. V ní vytvořit složku "com_menus"
4. V ní vytvořit soubor "item.xml"
5. Do něj vložit kód, který doplní pole v nastavení menu položky: záložka Zobrazení stránky > pole Počet znaků
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="n3tfields">
<fieldset name="page-options" label="Zobrazení stránky">
<field name="limit_introtext" type="text" label="Počet znaků" />
</fieldset>
</fields>
</form>
6. V rootu šablony vytvořit složku "helpers"
7. V ní vytvořit soubor "html.php"
8. Do něj vložit kód:
<?php
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
class templateHtml
{
public static function menufield($fieldName, $default = null)
{
if (class_exists('\\n3tFields')) {
$app = Factory::getApplication();
$menu = $app->getMenu();
$activeMenu = $menu->getActive();
if ($activeMenu)
return n3tFields::menu($activeMenu, $fieldName, $default);
}
return $default;
}
}
9. V souboru pro overrite (šablona/html/com_content/category/) blog_item.php doplnit kód pod řádky s use:
// Zkrácení introtextu | true = neusekává slova | true = s html tagy
HTMLHelper::addIncludePath(JPATH_BASE.'/templates/' . Factory::getApplication()->getTemplate() . '/helpers');
$limitintrotext=HTMLHelper::_('template.html.menufield','limit_introtext',200);
$this->item->introtext=HTMLHelper::_('string.truncate', $this->item->introtext, $limitintrotext, true, false);
