Skip to:
Content
Pages
Categories
Search
Top
Bottom

renaming index.php messes up lay-out?

  • Hi,

    Was just playing around and renamed index.php to home.php. The funny thing is, this simple rename effects the lay-out. Why is that? I mean no coding is touched, the file is just renamed!

    Also <?php new_topic(); ?> doesn’t display anymore and the underlining of the <h2> tags is gone as well.

    I am kinda noob, so why does this happen? no css or template is touched, it should work even if index.php is renamed….. not?

    What do I need to change so the lay-out and <?php new_topic(); ?> will NOT be effected when renaming index.php to home.php?

    Thx

Viewing 14 replies - 1 through 14 (of 14 total)
  • because of the function bb_get_location() in template-functions.php it returns front-page if $_SERVER['PHP_SELF'] is index.php

    well I found the function and added this one:

    case 'home.php' :

    return 'home-page';

    break;

    Where home-page is the front-page renamed aswell but this aint working either, it’s still messed up

    why would you have it return home-page when everything is expecting front-page?

    Why doesnt this work? Re-checked the functionsfile 3 times now, but no where else in the file it asks for this.

    I am experimenting with this new home.php page and adding these new functions to the file and renaming front-page.php aint solving the problem.

    What files more need to be changed in order to make home.php and home-page.php work just like index.php and front-page.php (which I renamed)?

    Thx

    edit:

    Changing:

    case 'home.php' :

    return 'home-page';

    break;

    to

    case 'home.php' :

    return 'front-page';

    break;

    Fixes the lay-out mess up, but still… WHY? Why doesn’t the renamed file home-page.php (front-page.php) work when the return is changed too?

    because of the function is_front(). It returns true if bb_get_location returns front-page.php.

    I also added is_home () same result…

    what do you think calls “is_home()”?

    Look, do what I told you originally. Change everything back to how it was, and JUST change home.php in the function bb_get_location() in template-functions.php.

    …… but then it would be identified as front-page as well. I am just curious of how this all works.. just wanna learn/understand…. Personally I find it strange so much needs to be changed to add a new page to the forum (even when renaming 1)

    What does it matter that what bbpress sees at “front-page” isn’t the actual front page of your site? It’s just a moniker used throughout the program, it doesn’t have to mean anything to you.

    Not a lot needs to change when adding a new page. Make a file in your forums root directory call it whatever, like null.php. set it up like this:

    <?php

    require_once('./bb-load.php');

    ***[if you need any code, put it here]***

    if ( file_exists(BBPATH . 'my-templates/nullsfile.php') ) {

    require( BBPATH . 'my-templates/nullsfile.php' );

    } else {

    echo "File does not exist in my-templates folder";

    }

    ?>

    Then make a file in your my-templates folder called nullsfile.php and make it look like an html file, but be sure to set it up like this:

    <?php bb_get_header(); ?>

    ***[put all your html code here with calls to php functions]***

    <?php bb_get_footer(); ?>

    At that point, you have a page integrated into bbpress. What you do in those two files is up to you. To access the file, you just go to forumsroot/null.php (if you have pretty links turned on, you don’t need the .php part). If you need called functions, standard is to put them into a file in the my-plugins folder.

    In some of the plugins I’ve made, my main file does stuff like detects if something is set in the address line by checking the $_GET[] variable, or it pulls information needed by the required my-templates file by running a database query…

    That all make sense?

    Quote:

    What does it matter that what bbpress sees at “front-page” isn’t the actual front page of your site? It’s just a moniker used throughout the program, it doesn’t have to mean anything to you.

    Well wrong, I am working on a menu for the forum and it defeniatily is important that the call back is accurate.

    Some excample code menu:

    <li<?php

    if ( is_front())

    {

    echo " id="current">";

    ?>

    <a href="<?php option('uri'); ?>">Forums</a>

    <?php

    }

    ?></li>

    Here you can see is_front and we also have is_forum so I need to add is_home aswell in order to make the menu work :)

    Well I understand your explaination of how things work. I started home.php from index.php and edited/deleted things i didn’t need to make my own startpage. I also wanted to keep the normal index file, thats why I renamed them. Unfortunally the addons i did in the template functions don’t work unless i keep it like this:

    case 'home.php' :

    return 'front-page';

    break;

    And then the id won’t work too, cause is_front() is called (and not is_home) so it gets the front-page id.

    Well going to release my project very soon (as soon as I found a solution for my DIV problem), perhaps you can help me better then.

    Really appreciate the time helping me out!!

    Null

    It sounds like what you need is to overload the bb_get_location function. This is easy to do in bbpress. You need to make a set of functions like this:

    is_home() {

    if( 'home-page' == get_bb_location() )

    return true;

    else

    return false;

    }

    get_home_location() {

    if ( bb_find_filename($_SERVER['PHP_SELF']) == 'home.php' )

    return 'home-page';

    }

    apply_filter( 'get_bb_location', 'get_home_location' );

    That’s untested, but I think that should work. Basically what you want to do is add in your locational test when bb_location is called. Then you can just call is_home() and it’ll do what you want. Of course, if you don’t want any other part of the forum to care if it’s on the home or not, you can take out all that stuff at the end that integrates it with get_bb_location, and just do this:

    is_home() {

    if( 'home-page' == get_home_location() )

    return true;

    else

    return false;

    }

    get_home_location() {

    if ( bb_find_filename($_SERVER['PHP_SELF']) == 'home.php' )

    return 'home-page';

    }

    Whichever you want to do. The second is easier, the first is more versatile.

    <li<?php

    if ( is_front())

    {

    echo " id="current">";

    ?>

    BTW the list item would be better described as being something like class="current" then add an appropriate .current {} to your css.

    See also: https://bbpress.org/forums/topic/250

    ardentfrost, I do this in template-functions.php I presume?

    Don’t ever change a core file ever.

    Put it in a new file in your my-plugins directory.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Skip to toolbar