2022 EduSoho开发日常之一 个人中心增加页面
引用代码
sidebar.html.twig
{{ slot('my.account.menu.extension', {'sideNav': side_nav}) }}
{{ slot('my.account.menu.extension.invoice', {'sideNav': side_nav}) }}
注册Slot
slots.yml
# 我的账户中心,左侧列表
- name: my.account.menu.extension
class: KeshifenPlugin\Slot\MyAccountMenuSlot
priority: 256
Slot代码
MyAccountMenuSlot
<?php
/*
* 作者:少宇 - 赛驰网络
* 联系:170 33333 111
* 时间:2022/2/15 下午3:55
* 网址:https://www.saichinet.com
*
* 山东赛驰网络科技有限公司
* Shandong Search Network Technology Co., Ltd.
* Copyright © 2012-2020 Search Network, All Rights Reserved
*/
namespace UserUidPlugin\Slot;
use Codeages\PluginBundle\System\Slot\SlotInjection;
class MyAccountMenuSlot extends SlotInjection
{
public function inject()
{
$sideNav = $this->sideNav;
return $this->container->get('twig')->render('KeshifenPlugin:Slot:my-account-menu.html.twig', array(
'side_nav' => $sideNav,
));
}
}
Slot模板
my-account-menu.html.twig
<li class="cd-sidebar__item {% if side_nav|default() == 'my-keshifen' %} active {% endif %}">
<a href="{{ path('my_keshifen') }}">{{ '课时分'|trans }}</a>
</li>