Jump to content

slider for sidebar


nimafire

Recommended Posts

some third-party templates might have sliders, but not aware of any addon that can create them for sidebars.... technically, it wouldn't be difficult though... just find a slider (plenty free online) and then add the required slider source code to the body of the sidebar... if it's purely an image slider (no text etc), then it should be simple... the trick will be finding the correct slider...

Link to comment
Share on other sites

Hi Nimafire,

you can use a BS4 Carousel if you wanna just slide some pictures.

<div id="demo" class="carousel slide" data-ride="carousel">

  <!-- Indicators -->
  <ul class="carousel-indicators">
    <li data-target="#demo" data-slide-to="0" class="active"></li>
    <li data-target="#demo" data-slide-to="1"></li>
    <li data-target="#demo" data-slide-to="2"></li>
  </ul>

  <!-- The slideshow -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="la.jpg" alt="Los Angeles">
    </div>
    <div class="carousel-item">
      <img src="chicago.jpg" alt="Chicago">
    </div>
    <div class="carousel-item">
      <img src="ny.jpg" alt="New York">
    </div>
  </div>

  <!-- Left and right controls -->
  <a class="carousel-control-prev" href="#demo" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#demo" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>

</div>

https://www.w3schools.com/bootstrap4/bootstrap_carousel.asp

Greetings Christian

 

Link to comment
Share on other sites

On 06/08/2018 at 05:29, wp4all said:

you can use a BS4 Carousel if you wanna just slide some pictures.

except I don't believe WHMCS supports BS4 yet, so you'd have to resort to using BS3.

HGrV6KK.png

https://www.screencast.com/t/cZVAfydiC

<?php

# Image Slider Sidebar for @nimafire
# Written by brian!
 
add_hook('ClientAreaSidebars', 1, function()
{
	GLOBAL $smarty;
	$templatefile = $smarty->getVariable('templatefile');
	$allowedpages = ['clientareahome','homepage'];
	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('slider1')
			->setLabel($title)
			->setBodyHtml($bodyHtml);
	}
});

i've trimmed the above example sidebar hook down to its bare bones - so the navigation controls have been removed... but you can easily add them back if required...

pXgLybi.png

as currently coded, the sidebar is only going to be shown on two pages - the homepage (non-logged in users) and client homepage (logged-in clients)... you can expand that list it necessary be editing the array in the hook and adding the relevant templatename to it...

$allowedpages = ['clientareahome','homepage'];

i've added a caption and link to the first image to show how to do that... the hook itself could be expanded to display different sliders on specific pages, or sliders based on whether the user is logged in or not... the sky is the limit, so let your imagination run free! 😀

if you need to change the sidebar's position with regards to the other sidebars, you can either use ->moveToBack() to move it to the bottom, ->moveToFront() to move it to the top, or ->SetOrder to give it a specific order value to place it between existing sidebars (that order value will alter depending on the page and which sidebars are already shown there).

Link to comment
Share on other sites

  • 1 year later...

Hello,

Thank you, Brian, very much for the code. It helped me a lot.

Is it possible to add the slider to cart pages that have the sidebar? I added the names of the templates I wanted it to show on. However, it still doesn't show 😔.

I don't know that I am doing wrong.
Can you please help?

Link to comment
Share on other sites

you could try replacing the equivalent lines of code in the hook with...

	$templatefile = $smarty->getVariable('templatefile');
	$filename = $smarty->getVariable('filename');
	$allowedpages = ['clientareahome','homepage'];
	if (in_array($templatefile, $allowedpages) OR $filename == "cart") {

xaZz0Go.png

and that should add the sidebar to each step of the cart process, but not the MarketConnect sales pages.

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