Advertisement:

Author Topic: No way to add rotating ad banner in OSCLASS ?  (Read 1380 times)

zerotechz

  • Newbie
  • *
  • Posts: 6
No way to add rotating ad banner in OSCLASS ?
« on: September 04, 2016, 06:37:55 am »
I'm using the osclasswizards theme and trying to get it set up but would like an ad banner set up that rotates a few banners to advertise businesses around my area...I'm not wanting Google Ads but am wanting to create images for the container...I've looked through google and can't seem to find anything over this subject..I've found a few things here and there and they don't work...Is it possible to do this ? If so could someone give me a good tutorial as to how to do it? Surely it's possible

gave

  • Newbie
  • *
  • Posts: 26
Re: No way to add rotating ad banner in OSCLASS ?
« Reply #1 on: September 04, 2016, 06:11:40 pm »
Hey,

A) depends if you want to hardcode it into your theme, eg:
- create a folder, 'banners' or like
- create a function, inside functions.php which reads all *.jpg into an array, then use shuffle() to mix em up, and print the first element

B) or the ability to add banners from Admin area,
- you'd have to create a form on your admin so you can load the files into a folder like above^, then the process is pretty much the same.

C) There might be a plugin already that gets you there or halfway,i dont remember one right now  :-[

zerotechz

  • Newbie
  • *
  • Posts: 6
Re: No way to add rotating ad banner in OSCLASS ?
« Reply #2 on: September 04, 2016, 06:34:38 pm »
On point A) -I've attempted that in something like that of the tutorials I've found throughout Google but haven't messed with functions.php...I had created a folder named "top banners" and then created a js file with no luck..If you could tell exactly how to create that (as in the code and where to place it ) I would appreciate that...

B) -would be even better
C) I've looked in alot of places for a plugin and even attempted to use one outside of OSCLASS and it didn't work either..

gave

  • Newbie
  • *
  • Posts: 26
Re: No way to add rotating ad banner in OSCLASS ?
« Reply #3 on: September 04, 2016, 08:06:58 pm »
Hey,
it's a bit clunky and basic, but try this:

1. upload a folder called banners with your images in .jpg( can change this in the function)
2. edit your functions.php file in your theme's folder ,and add:

Code: [Select]
function showBanner(){

//read all .jpgs from theme folder's banner folder

$themePath = WebThemes::newInstance()->getCurrentThemePath();

$bannerDir = $themePath . '/banners/' ; //or your folder

$bannerArr = glob($bannerDir . '*.jpg');

//reorder the array
shuffle($bannerArr);

$bannerPath = osc_base_url() .'oc-content/themes/'. osc_current_web_theme();

$bannerArr[0] = str_replace($themePath, $bannerPath, $bannerArr[0]);

echo '<img src="'.$bannerArr[0].'" >';

}


3. Choose where to place it, eg: header.php or footer.php, then
 add this <div class="aBanner"><?php showBanner(); ?></div>


Not great for a number of reasons (missing alt and title), but it should work.
 :)
« Last Edit: September 04, 2016, 08:11:35 pm by gave »

aide2006

  • Guest
Re: No way to add rotating ad banner in OSCLASS ?
« Reply #4 on: October 12, 2016, 06:00:43 pm »
I know its an old post, i too wanted this, so I set up a completely different banner set up from OSCLASS, it has an admin area and rotates banners very well.
You can see it working here www.bikersbay.co.uk at the bottom of first page.
I tried to get it as a plugin, but gave up as it was too complicated for me.
It counts the page view, it counts the click through and gives a print out of such for the customers, its just getting pay per click to sort.