Jump to content

add html into sidebar hook


nimafire

Recommended Posts

Hello

im looking for a hook to add sidebar in all page and add these lines into it:

 

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="2000">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="https://images.png" class="img-responsive center-block">
    </div>
  </div>
</div>

Link to comment
Share on other sites

36 minutes ago, nimafire said:

Hello

im looking for a hook to add sidebar in all page and add these lines into it:

 

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="2000">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="https://images.png" class="img-responsive center-block">
    </div>
  </div>
</div>

Unless you know PHP I would advise you to do the following. Just stop using WHMCS menu's all together and create your own with HTML. You will have nothing but troubles now and in the future because someone smart at WHMCS decided to move the code from the templates (where it was before) to encoded files and now people require PHP to modify even the most basic menu items. Its wonderful to be able to modify content with hooks dynamically but all other companies that do this, complement this on top of the HTML code for those that want to edit it directly. This is was also true in the past with WHMCS, all the code was in the template files. Today you need to use PHP code to modify even the most basic things. This is not intuitive and you will find that most people new to WHMCS struggle with this hard and badly. So my advise for people new to WHMCS, is just don't use the WHMCS default templates menu's and create your own so you are free to change them however you want now and in the future. It sucks I know, but  the code that generates the menu's is encoded and you cannot modify it directly using vanilla clean HTML.

Edited by yggdrasil
Link to comment
Share on other sites

problem is this hook is just working on seconder pages like contact us or cart page not index

index.php file cant load when this hook is enable

 

<?php
 
use WHMCS\View\Menu\Item as MenuItem;
 
// Add social media links to the end of all secondary sidebars.
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
    // Add a panel to the end of the secondary sidebar for social media links.
    // Declare it with the name "slider" so we can easily retrieve it
    // later.
    $secondarySidebar->addChild('slider', array(
        'label' => 'Lable',
        'uri' => '#',
        'icon' => 'fa-thumbs-up',
    ));
 
    // Retrieve the panel we just created.
    $sliderPanel = $secondarySidebar->getChild('slider');
 
    // Move the panel to the end of the sorting order so it's always displayed
    // as the last panel in the sidebar.
    $sliderPanel->moveToBack();
 
    // Add a Facebook link to the panel.
    $sliderPanel->addChild('facebook-link', array(
        'label' => '<HTML CODE HERE>',

    ));
});

Link to comment
Share on other sites

56 minutes ago, brian! said:

any particular reason you couldn't use the Slider hook I wrote for you previously as a basis.... ?

you'd only need to add your code to $bodyhtml (assuming your code is valid).

Hey

thanks ive forgot to check thattopic

now check your hook , problem is (this hook limited to client area home page) all pages load fine but home page which this hook refer to cant load until ive remove the hook from server

Link to comment
Share on other sites

29 minutes ago, nimafire said:

now check your hook , problem is (this hook limited to client area home page) all pages load fine but home page which this hook refer to cant load until ive remove the hook from server

the hook on that page works fine - it only shows the sidebar on the two specified pages... copy the code exactly as is and see if it works= if it doesn't, enable Display Errors in setup -> general settings -> other and that should tell you where the error is.

46 minutes ago, nimafire said:

problem is this hook is just working on seconder pages like contact us or cart page not index

but that code isn't mine - that's from the  sidebar documentation.... I wouldn't necessarily trust any code in the WHMCS docs... espeiclaly when you're already using that social media sidebar on your site.

so take my hook from the previous thread, copy exactly as it is... if it works, then change the content of $bodyhtml; if it doesn't work, enable Display Errors and tell me the error.

Link to comment
Share on other sites

1 hour ago, yggdrasil said:

It sucks I know, but  the code that generates the menu's is encoded and you cannot modify it directly using vanilla clean HTML.

well you could modify any sidebar/navbar/panel in the template if you *really* wanted or had to, but I know what you mean - it's not like editing a menu or sidebar in the admin area, that's still old-school template editing (at least for now).

as i've said previously, v6 should have come with a menu/sidebar editor built-in - yes you can buy third-party addons that can do that for you, but a user shouldn't need to pay anyone to modify a menu (unless it's a very specific complex situation that requires a custom solution).

Link to comment
Share on other sites

2 minutes ago, brian! said:

well you could modify any sidebar/navbar/panel in the template if you *really* wanted or had to, but I know what you mean - it's not like editing a menu or sidebar in the admin area, that's still old-school template editing (at least for now).

as i've said previously, v6 should have come with a menu/sidebar editor built-in - yes you can buy third-party addons that can do that for you, but a user shouldn't need to pay anyone to modify a menu (unless it's a very specific complex situation that requires a custom solution).

you mean in version 7 , add hook file into includes/hook folder is the old way ?

Link to comment
Share on other sites

if you're running both the slider hook and the socialmedia hook, then there may be a clash with one line of it's code... ->moveToBack() - that is trying to move both sidebars to the bottom, but they can't both be there...

the solution would be to remove ->moveToBack() from one or both of them - frankly, it's a function I hardly ever use as it's much easier to give them an order value...

<?php

# Image Slider Sidebar for @nimafire
# Written by brian!
 
add_hook('ClientAreaSidebars', 1, function()
{
	GLOBAL $smarty;
	$templatefile = $smarty->getVariable('templatefile');
	$allowedpages = ['clientareahome','homepage','knowledgebase'];
	if (in_array($templatefile, $allowedpages)) {
		$secondarySidebar = Menu::secondarySidebar();
		$title = 'Image Slider';
		$bodyHtml = '<div id="myCarousel" class="carousel slide" data-ride="carousel">
		<div class="carousel-inner">
			<div class="item active">
				<a href="http://www.la">
				<img src="https://www.w3schools.com/bootstrap4/la.jpg" alt="First Slide">
				<div class="carousel-caption">
					<h4>Los Angeles</h4>
				</div>
				</a>
			</div>
			<div class="item">
				<img src="https://www.w3schools.com/bootstrap4/chicago.jpg" alt="Second Slide">
			</div>
			<div class="item">
				<img src="https://www.w3schools.com/bootstrap4/ny.jpg" alt="Third Slide">
			</div>
		</div>
</div>';
		$secondarySidebar->addChild('slider')
			->setLabel($title)
			->setBodyHtml($bodyHtml);
	}
});
10 minutes ago, nimafire said:

you mean in version 7 , add hook file into includes/hook folder is the old way ?

no it's the new way... the old, easier way was to just edit the html within a template.

the advantage of hooks is that you shouldn't have to update them after you update WHMCS - with template edits, you would.

Link to comment
Share on other sites

43 minutes ago, brian! said:

well you could modify any sidebar/navbar/panel in the template if you *really* wanted or had to, but I know what you mean - it's not like editing a menu or sidebar in the admin area, that's still old-school template editing (at least for now).

as i've said previously, v6 should have come with a menu/sidebar editor built-in - yes you can buy third-party addons that can do that for you, but a user shouldn't need to pay anyone to modify a menu (unless it's a very specific complex situation that requires a custom solution).

It should come with all options eventually but one should not remove the previous feature.

This is how normal software evolves:

1. Code. If you want to modify it, just edit the code.

2. Then you add hooks to your software. Great, now those hooks modify that code on point 1 for those that want to use hooks but those that don't can keep doing it on the code.

3. Finally, if you have time and resources, you add a visual GUI editor for newbies that really want a click and point interface. You still leave options 1 and 2.

WHMCS basically is doing this:

1. The only option was to modify code. This is how WHMCS worked for years.

2. Then hooks came to WHMCS, and they decided to remove 1 for those options !!!

3. In the future, I will not be surprised if they introduce that editor you mentioned and remove the hooks  all together for menus !!! So now you can only edit it with a very limited and basic click and point editor. Its their way or the highway approach !!! Forcing everyone to use their method of doing things which happens in most cases to be a downgrade. If you remove previous features, that is a downgrade for me.

Link to comment
Share on other sites

1 minute ago, yggdrasil said:

WHMCS basically is doing this:

1. The only option was to modify code. This is how WHMCS worked for years.

the option is still there... it's realistically not worth the effort (in 99.9% of cases), but it can be done.

2 minutes ago, yggdrasil said:

Then hooks came to WHMCS, and they decided to remove 1 for those options !!!

as I said, it's not removed, just trickier to do and you'd have to use Smarty to manipulate the output.

3 minutes ago, yggdrasil said:

3. In the future, I will not be surprised if they introduce that editor you mentioned and remove the hooks  all together for menus !!!

they won't remove hooks now... and only WHMCS could release an editor 3+ years after launching the new menus system... though that's still quicker than a feature request lol.

7 minutes ago, yggdrasil said:

So now you can only edit it with a very limited and basic click and point editor. Its their way or the highway approach !!! Forcing everyone to use their method of doing things which happens in most cases to be a downgrade. If you remove previous features, that is a downgrade for me. 

they wouldn't do that either - if they did, then third-party devs would bring out better solutions... but WHMCS wouldn't do that... they're daft - but not that daft. 😛

Link to comment
Share on other sites

7 minutes ago, brian! said:

the option is still there... it's realistically not worth the effort (in 99.9% of cases), but it can be done.

as I said, it's not removed, just trickier to do and you'd have to use Smarty to manipulate the output.

they won't remove hooks now... and only WHMCS could release an editor 3+ years after launching the new menus system... though that's still quicker than a feature request lol.

they wouldn't do that either - if they did, then third-party devs would bring out better solutions... but WHMCS wouldn't do that... they're daft - but not that daft. 😛

That is not true. WHMCS told me this on tickets before (unless this changed now on 7.6). The code is encoded. Replicating the functions is not the same. You are just recreating what it does, you are not editing the direct menu functions. At least out of the box (a new WHMCS install), it was removed.

Edited by yggdrasil
Link to comment
Share on other sites

45 minutes ago, yggdrasil said:

That is not true.

which bit?

45 minutes ago, yggdrasil said:

WHMCS told me this on tickets before.

just because WHMCS tell you something can't be done - don't feel obliged to believe them... they told me the same 5 years ago when I first started, and an hour later I proved them wrong... and that was with no knowledge of Smarty back then... i'd take statements like that from them with a pinch of salt now.... might be true, might not be.

45 minutes ago, yggdrasil said:

You are just recreating what it does, you are not editing the direct functions.

how do you know what i'm doing - I haven't told you how i'm doing it! lol

let's simplify what i'm saying... if your question is: "can menus (e.g navbar in this instance - but applies to sidebars and panels) be changed by editing a template without using any hooks?"...  then the plain answer is Yes.

it is easy ? for a newbie, No.

is it worth the effort ? in most circumstances, No.

is it editing HTML? No... it's a Smarty template, so you need to use more Smarty to manipulate it.

Can I add, edit or remove menu items in the template ? Yes... though adding might be a little trickier, but I suppose doable.

if WHMCS support specifically told you that it can't be done, then fine... one of the golden rules working on a helpdesk, is often not to make work for yourself - and if they'd said yes, then your next question would have asked how to do it... 😀

in reality, WHMCS want you to use hooks... and in almost all circumstances I can think of (off the top of my head, I can't think when i'd do it in the template - unless hooking was too difficult in a specific situation), hooks would be an easier way to do it.

let's say I wanted to change the Home label in the navbar... it's a simple hook... or you can do it in the template... you'll have to take my word for it when I tell you that the navbar below was modified by two lines of code in an existing template with absolutely no hooks... that's hardly recreating the function... it's taking the existing function and manipulating it while it's running.

DVdXUpP.png

I could do the same with links, icons, badgets etc - but it's far easier to do it with a hook. 😀

Link to comment
Share on other sites

13 hours ago, brian! said:

which bit?

just because WHMCS tell you something can't be done - don't feel obliged to believe them... they told me the same 5 years ago when I first started, and an hour later I proved them wrong... and that was with no knowledge of Smarty back then... i'd take statements like that from them with a pinch of salt now.... might be true, might not be.

how do you know what i'm doing - I haven't told you how i'm doing it! lol

let's simplify what i'm saying... if your question is: "can menus (e.g navbar in this instance - but applies to sidebars and panels) be changed by editing a template without using any hooks?"...  then the plain answer is Yes.

it is easy ? for a newbie, No.

is it worth the effort ? in most circumstances, No.

is it editing HTML? No... it's a Smarty template, so you need to use more Smarty to manipulate it.

Can I add, edit or remove menu items in the template ? Yes... though adding might be a little trickier, but I suppose doable.

if WHMCS support specifically told you that it can't be done, then fine... one of the golden rules working on a helpdesk, is often not to make work for yourself - and if they'd said yes, then your next question would have asked how to do it... 😀

in reality, WHMCS want you to use hooks... and in almost all circumstances I can think of (off the top of my head, I can't think when i'd do it in the template - unless hooking was too difficult in a specific situation), hooks would be an easier way to do it.

let's say I wanted to change the Home label in the navbar... it's a simple hook... or you can do it in the template... you'll have to take my word for it when I tell you that the navbar below was modified by two lines of code in an existing template with absolutely no hooks... that's hardly recreating the function... it's taking the existing function and manipulating it while it's running.

DVdXUpP.png

I could do the same with links, icons, badgets etc - but it's far easier to do it with a hook. 😀

My point is that it does not come out of the box. A new person installing WHMCS, looks the templates or WHMCS files and is not going to find the menus. So yes, you are recreating the code. Even if you are creating new code or taking code from the old templates. On every new upgrade, the default themes will overwrite them. Since I use the default themes as "WHMCS original code" and always compare them with my templates to merge changes. Someone installing WHMCS will not be able to modify the menus looking the templates, unless he comes here to the community and asks how. When I first purchased WHMCS this was not so. The smarty code was inside the templates. I'm not sure if they are trying to get rid of smarty, I would not be surprised. I recently contacted my IDE developer about a bug in smarty and their reply was that it will most likely not be added as Smarty is old and the new smarty is twig. I told him Smarty is still updated and is faster in performance than Twig and there is no reason I will replace it just because "twig" or "laravel" (which is also horrible slow, reason why WHMCS is also now slower vs older versions) just because they are the new fashion. Frameworks change all the time and I'm not planning on changing or re-learning new stuff every time there is something new in town. In particular when smarty is still updated and an active project.

WHMCS has removed the smarty code menus from templates. Out of the box its not there anymore. I think this is what I was trying to transmit in my previous reply.

Link to comment
Share on other sites

5 hours ago, yggdrasil said:

My point is that it does not come out of the box.

does it come in a nice easy editable html file with a hrefs ? no.... I suspect those days are long gone.

5 hours ago, yggdrasil said:

A new person installing WHMCS, looks the templates or WHMCS files and is not going to find the menus.

correct - which is why I said there should have been a menu editor built into v6...

5 hours ago, yggdrasil said:

So yes, you are recreating the code.

i'm sorry, we'll never agree on that point... the menus are output via existing specific template(s) and i'm just manipulating the code within those template(s) directly.. i'm not reinventing the wheel; i'm not creating a new menu system - i'm taking what is already there and tweaking it in a couple of Smarty lines.

5 hours ago, yggdrasil said:

On every new upgrade, the default themes will overwrite them.

absolutely - and that's why editing files is old hat.... the same would exist if the client area was using a href links like the admin... if you modified them, they'd get overwritten too.

5 hours ago, yggdrasil said:

Someone installing WHMCS will not be able to modify the menus looking the templates, unless he comes here to the community and asks how.

or they read the docs, or buy third-party addons to let them manage them within WHMCS...

is it crazy that WHMCS decided to impose this on their customer base?  absolutely.

5 hours ago, yggdrasil said:

When I first purchased WHMCS this was not so. The smarty code was inside the templates.

the current menus are still output via Smarty... difference now is that the content of them is stored in arrays.

5 hours ago, yggdrasil said:

I'm not sure if they are trying to get rid of smarty, I would not be surprised.

I hope not.

5 hours ago, yggdrasil said:

I recently contacted my IDE developer about a bug in smarty and their reply was that it will most likely not be added as Smarty is old and the new smarty is twig.

never forget that WHMCS didn't write this menu system - it's from a third party... and it can be used with twig too... no point worrying what might happen with v8, whatever happens happens - though if they made such a fundamental change, there would have to be one hell of a long beta period.

5 hours ago, yggdrasil said:

WHMCS has removed the smarty code menus from templates. Out of the box its not there anymore. I think this is what I was trying to transmit in my previous reply.

I don't think that they have... they're still there, just in a different way than from before.

and out of the box is relative - there are some WHMCS users that don't even know basic HTML... so they'd be hard pushed to modify any sort of menu without a tool.

however, I suspect we've hijacked this thread for too long now, so we'll close it there.

@nimafire - did you manage to get it working in knowledgebase? looking at the site, it looks not...

Link to comment
Share on other sites

23 hours ago, brian! said:

however, I suspect we've hijacked this thread for too long now, so we'll close it there.

No worries, *someone* will shortly.
Complaints about how things are done tend to be labeled "out of hand" and closed here. ("my way vs highway" comes to mind)

Link to comment
Share on other sites

41 minutes ago, bear said:

Complaints about how things are done tend to be labeled "out of hand" and closed here.

it's much simpler to shutdown some troubling voices rather than dealing with the issues being talked about... sadly, they'll find out eventually that sticking your fingers in your ears doesn't make the problems go away, they just get worse.

although it's strange that the one thread I thought would get closed, hasn't been... i've still got it bookmarked, and when I find the time, i'll return to it as i've still got a few more things to say on that matter.

Link to comment
Share on other sites

2 hours ago, brian! said:

it's much simpler to shutdown some troubling voices rather than dealing with the issues being talked about... sadly, they'll find out eventually that sticking your fingers in your ears doesn't make the problems go away, they just get worse.

although it's strange that the one thread I thought would get closed, hasn't been... i've still got it bookmarked, and when I find the time, i'll return to it as i've still got a few more things to say on that matter.

Open discussion is healthy for a company. It allows WHMCS to see what their customers think or how they use the product. There is a reason why companies like Google or Facebook are huge. Because of all the information they have. In that sense, having more information about how someone is using a product and what they want to achieve with it should be considered as valuable insight for WHMCS. Of course, in the end they can still do what ever they want but having a voice should be important for all customers. I noticed for example that companies that don't have a community or community seem to be less successful than those that have one. Because people will still create a community around a brand or product, even if you don't have an official site on which they can post.  They will use a third party system, an external forums, a social network, what ever. So its really bad to close down topics or try to silence criticism because all you get with those action is moving discussions to outside systems where they can't control dissident voices.

Edited by yggdrasil
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