Jump to content

home page panel: add array title and target to href


wulfric

Recommended Posts

How do I make a list item link have added arrays like target and title? <a href="uri" title="link stuff goes here" target="_blank">label</a>

 

Here is the code I ripped from the docs and a few other links, but I need your help so I can get results!

 

<?php

use WHMCS\View\Menu\Item;

add_hook('ClientAreaHomepagePanels', 1, function($homePagePanels) {
   $newPanel = $homePagePanels->addChild(
       'helpful-links',
       array(
           'name' => 'Helpful Links',
           'label' => 'Helpful Links',
           'icon' => 'fa-pie-chart',
           'order' => '10',
           // 'extras' => array(
           //     'btn-link' => '/xyz',
           //     'btn-text' => 'Resource',
           // ),
       )
   );

   $newPanel->addChild(
       'helpful-page',
       array(
           'label' => 'Goto a <u>helpful page</u> to check guides and stuff',
           'uri' => '/abc',
           'order' => 10,
           '[b]target[/b]' => 'blank',
           '[b]title[/b]' => 'link title here',
       )
   );
});

 

Link to comment
Share on other sites

try doing something like this...

 

<?php

# HomePagePanel Hook
# Written by brian!

use WHMCS\View\Menu\Item;

add_hook('ClientAreaHomepagePanels', 1, function(Item $homePagePanels) {

   $html = '<p>Goto a <a href="http://www.google.com" target="_blank">helpful page</a> to check guides and stuff</p>';

   $homePagePanels->addChild('Helpful Links', array(
                       'label' => 'Helpful Links',
                       'icon' => 'fa-pie-chart',
                       'order' => 10,
                       'extras' => array(
                           'color' => 'blue',
                           'btn-link' => 'http://www.google.com',
                           'btn-text' => 'Google',
                           'btn-icon' => 'fa-google',
                           ),
                       'bodyHtml' => $html,
                       ));
});

that way, if you want to change the body of the panel, you just need to edit $html - so if you want to add lists, you can add them there... if you've got arrays to work with, you can loop their output etc.

 

if you want to do it your way, then you'd do something like this...

 

add_hook('ClientAreaHomepagePanels', 1, function(Item $homePagePanels) {
   $homePagePanels->addChild('helpful-links', array(
                       'name' => 'Helpful Links2',
                       'label' => 'Helpful Links',
                       'icon' => 'fa-pie-chart',
                       'order' => '10',
                   )
   );

   $homePagePanels->getChild('helpful-links')
                   ->addChild('helpful-page', array(
                       'label' => 'Goto a <u>helpful page</u> to check guides and stuff',
                       'uri' => '/abc',
                       'order' => 10,
                   )    
   )
                   ->setAttribute("target", "_blank");
}); 

 

NGNxhTY.png

 

the big difference between the two is that with mine, only the "helpful page" text is hyperlinked; with yours the entire child is linked.

 

if you wanted to save even more space, you could just drop the bodyhtml and use the link in the top-right of the panel to go to your page...

 

<?php

# HomePagePanel Hook
# Written by brian!

use WHMCS\View\Menu\Item;

add_hook('ClientAreaHomepagePanels', 1, function(Item $homePagePanels) {

   $homePagePanels->addChild('Helpful Links', array(
                       'label' => 'Helpful Links',
                       'icon' => 'fa-pie-chart',
                       'order' => 10,
                       'extras' => array(
                           'color' => 'blue',
                           'btn-link' => 'http://www.google.com',
                           'btn-text' => 'Google',
                           'btn-icon' => 'fa-google',
                           ),
                       ));
});

 

CjZhxLv.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated