Jump to content

Moving 'View Cart' & 'Choose language' to a secondarySidebar, possible?


-M-

Recommended Posts

Hi guys,

 

Can someone tell me how I can correctly move the following two items:

 

- View Cart

- Choose language (with language selection options)

 

to a 'secondarySidebar' in the Client Area?

 

The reason I want to move these two items is that I want to get the design of WHMCS almost exactly the same as the main website (which is quite a pain to achieve by the way).

 

I tried a few things myself, but no luck.

 

Thank you in advance for helping out. Highly appreciated as always.

 

//edit

 

I am also fooling a bit around myself at the moment. I also noticed I don't know how to display {$LANG.viewcart} in a hook, for example in the following part:

 

   $secondarySidebar->addChild('example', array(
       'label' => 'labelname',
       'uri' => '#',
       'icon' => 'fa-example',
   ));

 

Where I want to replace 'labelname' with {$LANG.viewcart}. I tried using {$LANG.viewcart} there, but that didn't work. It will output it like it shows...?

 

On a sidenote; I wish there were a few more random examples in the docs (especially for people like me with zero coding skills).

Edited by MvdL1979
Added (another) noobish question. :S
Link to comment
Share on other sites

Can someone tell me how I can correctly move the following two items:

 

- View Cart

- Choose language (with language selection options)

 

to a 'secondarySidebar' in the Client Area?

i'll deal with the easier one first - view cart! :)

 

to remove the existing 'View Cart' link, you'll need to edit header.tpl and remove (or remark out) the 3-line <div> block ~ line 75 for 'Shopping Cart'.... btw, same would go for language @ line 23

 

then to add a view cart link to a secondary navbar, create a file in the includes/hooks folder, call it secondaryviewcart.php (or anything you like!) and add the following into it.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
   $secondaryNavbar->addChild('View Cart', array(
               'label' => Lang::trans('viewcart'),
               'uri' => 'cart.php?a=view',
               'order' => '0',
           ));
});

Where I want to replace 'labelname' with {$LANG.viewcart}. I tried using {$LANG.viewcart} there, but that didn't work. It will output it like it shows...?

there are a few ways the above could be achieved, but the method used in the hook is the 'official' way I believe for v6!

 

On a sidenote; I wish there were a few more random examples in the docs (especially for people like me with zero coding skills).

count yourself lucky that you weren't here a few months ago straight after the v6 release - we still had the same poor documentation with many basic features left unexplained... and it's only by trial & error that a few of us have filled (some of) the gaps! :)

 

going back to the language part, I doubt you could move the black language overlay to a navbar menu link, so the alternative would be to add 24 children to a new navbar menu item - but that might be too large for most users!

 

v5 has a dropdown menu to select language - depending on your site design, that may be a better option that adding another item to the navbar.

 

edit - just noticed you said sidebar and not navbar, but the principles are the same - just change Navbar to Sidebar in the code! :roll:

 

additionally, if you're using it as a sidebar, you may also need to tweak the code to only show it on certain appropriate pages and not all of them.

Edited by brian!
Link to comment
Share on other sites

Thanks once again Brian.

 

You really make everything sound so simple and easy. :)

I will give it a go as you described.

 

And in regards to the language, I stripped most languages. So there are only 3 languages left. I don't mind having them in a panel. :)

But I think I might have a solution of that language thing. I just copy the URL to change the language (doing this for each of the 3 languages). Don't know if this will work. But I guess it should. :)

 

In regards to the documentation; yeah, I remember looking at WHMCS several years ago, but since documents were lacking, I decided to go a different route back then.

 

Anyways, thanks for the answers. Wish I could say this was the last time I needed help, but that would be lying. ;)

Link to comment
Share on other sites

You really make everything sound so simple and easy. :)

i'm like a swan - serene on top, but paddling furiously underneath! :)

 

And in regards to the language, I stripped most languages. So there are only 3 languages left. I don't mind having them in a panel. :)

But I think I might have a solution of that language thing. I just copy the URL to change the language (doing this for each of the 3 languages). Don't know if this will work. But I guess it should. :)

I was hoping you weren't wanting to add 24 languages and had stripped some of them - that simplifies things tremendously and allows you to effectively hard-code the links in a hook.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
   $secondarySidebar->addChild('Languages', array(
               'label' => Lang::trans('chooselanguage'),
               'order' => '0',
           ));
           $secondarySidebar->getChild('Languages')
           ->addChild('English', array(
               'label' => 'English',
               'uri' => '?language=english', 
           ));
           $secondarySidebar->getChild('Languages')
           ->addChild('French', array(
               'label' => 'French',
               'uri' => '?language=french',                
           ));
           $secondarySidebar->getChild('Languages')
           ->addChild('Spanish', array(
               'label' => 'Spanish',
               'uri' => '?language=spanish',                
           ));
});

Link to comment
Share on other sites

i'm like a swan - serene on top, but paddling furiously underneath! :)

 

 

I was hoping you weren't wanting to add 24 languages and had stripped some of them - that simplifies things tremendously and allows you to effectively hard-code the links in a hook.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
   $secondarySidebar->addChild('Languages', array(
               'label' => Lang::trans('chooselanguage'),
               'order' => '0',
           ));
           $secondarySidebar->getChild('Languages')
           ->addChild('English', array(
               'label' => 'English',
               'uri' => '?language=english', 
           ));
           $secondarySidebar->getChild('Languages')
           ->addChild('French', array(
               'label' => 'French',
               'uri' => '?language=french',                
           ));
           $secondarySidebar->getChild('Languages')
           ->addChild('Spanish', array(
               'label' => 'Spanish',
               'uri' => '?language=spanish',                
           ));
});

 

Yeah, 20+ languages would be insane, unless you use a dropdown or similar. But I only want to use 3 languages anyways. :)

Anyways, worked perfectly. Thank you Brian!

 

//edit #1

 

I edited the cart hook, however the text is showing up, but the cart is not?

 

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
   $secondarySidebar->addChild('View Cart', array(
               'label' => Lang::trans('viewcart'),
               'uri' => 'cart.php?a=view',
               'order' => '0',
           ));
});

 

Only the cart's name (in selected language shows up), but no link or anything else, just white-space?

 

Did I do something wrong?

 

//edit #2

 

Well I managed to get it working. Thanks to the code you provided with change language settings:

 

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {
   $secondarySidebar->addChild('ViewCart', array(
               'label' => Lang::trans('viewcart'),
               'order' => '0',
           ));
           $secondarySidebar->getChild('ViewCart')
           ->addChild('ViewCart', array(
               'label' => Lang::trans('viewcart'),
               'uri' => 'cart.php?a=view',             
           ));
});

 

Is this the correct way?

 

The only minor issue I am having now, is that it showing the sidebar also on the main page (where you do a domainname lookup and stuff, but I guess I will have to hide it there.

 

Thank you. :)

Edited by MvdL1979
fixed it. :)
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