Guest User

Untitled

a guest
Oct 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  2. <body>
  3. <referenceBlock name="top.links">
  4. <block class="Your_NamespaceYour_ModulenameBlockLink" name="custom-link" after="my-account-link"/>
  5. </referenceBlock>
  6. </body>
  7. </page>
  8.  
  9. namespace Your_NamespaceYour_ModulenameBlock;
  10. /**
  11. * Class Link
  12. *
  13. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  14. */
  15. class Link extends MagentoFrameworkViewElementHtmlLink
  16. {
  17. /**
  18. * Template name
  19. *
  20. * @var string
  21. */
  22. protected $_template = 'Your_Namespace_Your_Modulename::link.phtml';
  23.  
  24. /**
  25. * @param MagentoFrameworkViewElementTemplateContext $context
  26. * @param array $data
  27. */
  28. public function __construct(
  29. MagentoFrameworkViewElementTemplateContext $context,
  30. array $data = []
  31. ) {
  32. parent::__construct($context, $data);
  33. }
  34.  
  35. /**
  36. * @return string
  37. */
  38. public function getHref()
  39. {
  40. return $this->getUrl('custom/controller/action');
  41. }
  42.  
  43. /**
  44. * @return MagentoFrameworkPhrase
  45. */
  46. public function getLabel()
  47. {
  48. return __('Your custom link');
  49. }
  50. }
  51.  
  52. <li class="link custom">
  53. <a <?php /* @escapeNotVerified */ echo $block->getLinkAttributes() ?>><?php echo $block->escapeHtml($block->getLabel()) ?></a>
  54. </li>
Add Comment
Please, Sign In to add comment