Linktree - remove forum index on custom home page

Started by cowboytns, July 13, 2010, 11:55:05 PM

Previous topic - Next topic

cowboytns

I have created a custom home page based on my forum theme.  My custom homepage address is: http://brainmush.net/forum2/home.php?page=brainmush and the code is:
<?php

$ssi_gzip
= true;  //true--means gzip is turned on.
$ssi_ban = true;  //true--means a banned forum user will be banned also in the SSI page.
// Comment out the line below to use the forum's default theme. (what the Admin has set)

ob_start();  //is needed not to get errors.

// Load up SSI
require(dirname(__FILE__) . '/SSI.php');

// Set up the page title
$context['page_title'] = 'Brainmush.net';
$context['page_title_html_safe'] = 'Brainmush.net';

// Set up linktree
$context['linktree'][] = array(
 
'url' => $_SERVER['PHP_SELF'],
   
);

// Initialize the template
template_init();

// Load up the headers
template_header();

// Load your template function
template_main();

// Load the template footer
template_footer();

// Set up the main template
function template_main()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" class="catbg">Brainmush.net Is Going To Rock!</td></tr>

<tr>
    <td>
        <p align="justify"><b>Welcome to Brainmush.net.  Currently this site is under construction.  However, some of the ideas that we are planning are described here.  Take a look and let us know what you think in the forums.</b></p>
    </td>
</tr>

</table><br>'
;

echo
'
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="top">
<td width="50%">
<table cellpadding="2" cellspacing="0" border="0" align="top">
<tr>
    <td width="50%" class="catbg">Forum
    </td>
</tr>
<tr>
    <td width="50%">
         <p align="justify">Eventually all of the topics from the old forum will be moved to the new forum.  There are hopes that we will be able to provide topic previews on this webpage on the forum discussions.</p>
    </td>
</tr>
<tr>
    <td width="50%" class="catbg">News
    </td>
</tr>
<tr>
    <td width="50%">
         <p align="justify">The news area gives us a place to combine headlines from several news sources that our contributors prefer.  All contributors are encouraged to let the site administartors know of any news sources that they would like to see on the site.</p>
    </td>
</tr>
<tr>
    <td width="50%" class="catbg">The Reading Room
    </td>
</tr>
<tr>
    <td width="50%">
         <p align="justify">The reading room will have two sections:  book reviews and book discussions.  The book reviews section will contain books reviewed by site contributors and possibly guests.  Hopefully we will be able to figure out how to sort the book reviews by several parameters: author, title, subject, type, etc.  There will be a box at the bottom of the page for others to contribute a book review.  All reviews will not be posted until reviewd by the site administrators.</p>
    </td>
</tr>
</table>
</td>

<td width="8">&nbsp;</td>

<td width="50%" align="top">
<table cellpadding="2" cellspacing="0" border="0" align="top">
<tr>
    <td width="50%" class="catbg">TNA Brewing
    </td>
</tr>
<tr>
    <td width="50%">
         <p align="justify">This area of the site will be a dedication to one of the past times of the site founders, home brewing.  This will be a brief history of all of the brews that they have brewed throughout the history of their "brewery".</p>
    </td>
</tr>
<tr>
    <td width="50%" class="catbg">About Brainmush
    </td>
</tr>
<tr>
    <td width="50%">
         <p align="justify">Here information will be provided on the background for Brainmush.net.  Also there may be a place to briefly introduce the site founders and/or contributors.  This way users of the site may get a better feel for where an author of an article is coming from.</p>
    </td>
</tr>
</table>
</td>
</table>'
;
}



?>


When I am on my homepage I want the link tree to just have "Home."  I don't want: "Home >> Forum Index"

In order to get the "Home" value in front of the forum index I inserted this code into the sources/load.php file:

// Set the top level linktree up.
        array_unshift($context['linktree'], array(
'url' => $scripturl,
'name' => $context['forum_name_html_safe']
));

        array_unshift($context['linktree'], array(
'url' => 'http://brainmush.net/forum2/home.php?page=brainmush',
'name' => 'Home',


Does anyone have any ideas on how I can edit the linktree for the homepage?

Thanks

cowboytns

It really bugs me when people bump but does anyone have any ideas on what I can do or other posts I can read on this issue? 

As an alternative, does someone know how I can remove the linktree from my custom homepage (see coding in previous post) but leave it on all the forum pages?

IchBin™

I'm not sure I'm following exactly. Any reason you can't just unset() the part of the array that you don't want on your custom page?
IchBin™        TinyPortal

cowboytns

thank you for the reply.  However, you'll have to excuse my coding ignorance.  The unset() command you speak of may be what I need...however what exactly does it do and where would I apply it?  In my custom page I would imagine?

IchBin™

So you can use unset() to remove a variable set in PHP. Here's what the $context['linktree'] array looks like if you do a print_r() on it.
Array
(
    [0] => Array
        (
            [url] => http://www.mysite.com/index.php
            [name] => IchBin Here
        )

    [1] => Array
        (
            [url] => http://www.mysite.com/index.php?action=forum
            [name] => Forum
        )

    [2] => Array
        (
            [url] => http://www.mysite.com/index.php?action=forum#2
            [name] => Public
        )

    [3] => Array
        (
            [url] => http://www.mysite.com/index.php?board=11.0
            [name] => PHP Code Discussion
        )

)


To remove something from the linktree, you should be able to unset() any of those variables. For instance, if I wanted to remove the category name in the able example, I could do this before I echo out the linktree.

unset($context['linktree'][2]);
IchBin™        TinyPortal

cowboytns

Thank you ever so much.  I got it to do what I wanted it to do.  Using the unset() command you told me about, I just deleted the linktree from my custom page by doing the following:
I replaced:
// Set up linktree
$context['linktree'][] = array(
  'url' => $_SERVER['PHP_SELF'],
);


with:
// Set up linktree
$context['linktree'][] = array(
  'url' => $_SERVER['PHP_SELF'],
);
unset($context['linktree']);


In it's place I have created a linktree manually that will work just fine for all of the custom pages that I am going to create.

Again, thank you for your help.  This topic is SOLVED!

Advertisement: