Advertisement:

Author Topic: I need to add content below Header. Where is this part of the website? [SOLVED]  (Read 3567 times)

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Hi I have this function (for a slider plugin) which I need to add in my website. This is the function:
Code: [Select]
<?php osc_slider(); ?>
And in the image you can see where I need to add it (red box). I found a way to add it there, but that was going from the header.php file, which worked great, until I realized it is generated on every page... What file do I need to add the code in so it only appears on the home page? (I am running the latest OSClass and Bender theme)

Thanks
« Last Edit: July 15, 2014, 01:18:36 pm by ben_dchost1 »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Hi,

main.php (Homepage code)

Regards

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
thanks for reply. I looked in homepage and I tried adding the code like this:

Code: [Select]
<?php osc_current_web_theme_path('header.php') ; ?>
<?php osc_slider(); ?>
<div class="clear"></div>
<div class="latest_ads">

This displays like this: http://i.imgur.com/TY0q1cO.png

So If I try and add it above the first bit of code:
Code: [Select]
<?php osc_slider(); ?>
<?php osc_current_web_theme_path('header.php') ; ?>
<div class="clear"></div>
<div class="latest_ads">


It then displays like this: http://i.imgur.com/oHNADmZ.png

Any ideas what I can do?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Try this way, add this new function at the very bottom of bender/functions.php:

Code: [Select]
<?php function cust_show_slider() {
    
osc_slider();
}
osc_add_hook('before-main''cust_show_slider');
?>

Regards

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
IT WORKS! Thank you so much for your help! All morning been trying to figure it out  ;D.

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Do you know if there is a way to make it 100% width? So it stretches whole width of page? I probably have to create a new div for it so it can stretch out fully, but where would I do this? This is the website http://officesincambridge.co.uk and here is image http://i.imgur.com/rPSixeC.png

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Also it's still displaying on all the different pages (not just home page)

teseo

  • Hero Member
  • *****
  • Posts: 6169
For this:

Also it's still displaying on all the different pages (not just home page)

Code: [Select]
<?php function cust_show_slider() {
    if (
osc_is_home_page()) osc_slider();
}
osc_add_hook('before-main''cust_show_slider');
?>

The other thing, I'll get back to you later, now I'm busy.

Regards
« Last Edit: July 10, 2014, 03:39:22 pm by teseo »

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Thanks again Teseo for reply and no rush  :)

Just to let you know the function doesn't work (only display is header and the rest is blank) but I will try play around with it and inform you here if I figure out problem (complete guessing game!).

teseo

  • Hero Member
  • *****
  • Posts: 6169
Sorry, a typo, it's osc_is_home_page();

teseo

  • Hero Member
  • *****
  • Posts: 6169
Complete (indeed it's just to wrap the Slider in a simple div):

Code: [Select]
<?php function cust_show_slider() {
    if (
osc_is_home_page()) { ?>

         <div>
         <?php osc_slider(); ?>
         </div>
    <?php }
}
osc_add_hook('before-main''cust_show_slider');
?>

Regards
« Last Edit: July 10, 2014, 05:32:50 pm by teseo »

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
I am lurking   ;D

@ben
do this, as you are just getting started, it will solve some errors down the line. the first thing you will notice is the search button....

http://forums.osclass.org/3-3-x/are-you-sure-you-want-to-delete-your-account/15/

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Complete (indeed it's just to wrap the Slider in a simple div):

Code: [Select]
<?php function cust_show_slider() {
    if (
osc_is_home_page()) { ?>

         <div>
         <?php osc_slider(); ?>
         </div>
    <?php }
}
osc_add_hook('before-main''cust_show_slider');
?>

Regards

@teseo

Thanks again for all of your help, sorry I've only just got back to you only just got back into the office. The code works wonderfully! However, I am having a slight issue with the div. The div is generated within the .wrapper container, therefore it is limited to 980px; I can get by this by setting the div through absolute positioning, but this causes display issues, especially when looking at content on a smartphone etc.

Looking at the structure, the easiest way would be to close off the .wrapper container for the header and then reopen it after the slider. Would I need to close the .wrapper container div, and then have it reopen all of the pages which have a header? Or is there a way to close the wrapper div for only the main home page and then have the slider load, then reopen the wrapper?
(I hope this makes sense)
« Last Edit: July 15, 2014, 12:09:00 pm by ben_dchost1 »

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
I've managed to work it out!

I ended up removing the code which I added earlier from bender\functions.php
Remove:

Code: [Select]
<?php function cust_show_slider() {
    if (
osc_is_home_page()) { 
         echo 
'<div class="custom-slider">';?>

         <?php osc_slider(); ?>
         echo '</div>';
    <?php }
}
osc_add_hook('before-main''cust_show_slider');
?>

Then in bender\header.php

Find this:
Code: [Select]
<div class="wrapper" id="content">
<?php osc_run_hook('before-main'); ?>
<div id="main">
<?php osc_run_hook('inside-main'); ?>

And change it to this:
Code: [Select]
<?php if(!osc_is_home_page()){?>
<div class="wrapper" id="content">
<?php osc_run_hook('before-main'); ?>
<div id="main">
<?php osc_run_hook('inside-main'); ?>
<?php
}

Then in functions\main.php below: <?php osc_current_web_theme_path('header.php') ; ?>

Add this:
Code: [Select]
<?php osc_slider();?>
<div class="wrapper" id="content">
<?php osc_run_hook('before-main'); ?>
<div id="main">
<?php osc_run_hook('inside-main'); ?>

And it runs perfectly, allowing the website to support full width slider. I hope it helps someone :)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Oh, many ways to skin a cat, but it should suffice to change the hook, using before-content instead of before-main:

Code: [Select]
<?php function cust_show_slider() {
    if (
osc_is_home_page()) osc_slider();
}
osc_add_hook('before-content''cust_show_slider');
?>

Regards