Need help *replacing* the nav menu

Started by TheDisturbedOne, May 14, 2009, 07:07:45 PM

Previous topic - Next topic

TheDisturbedOne

I want to have a section of my site where the navmenu at the top (forgot the real name for it) is completely different then the one in the normal forum.

Instead of having:

Home  Help  Search  Admin  Calendar  Members  Logout


I want to have:

Forum     Stuff     More Stuff     Even More     Logout


But I still want to have the normal nav menu for the forum, so this would be a completely different menu.

Any idea on how I would code this?


If you cannot understand this, I'll try to explain better :D

JBlaze

Are you using a custom theme or the SMF Core Default?

Also, which version? 1.1.x or 2.0?
Jason Clemons
Former Team Member 2009 - 2012

TheDisturbedOne

Whoops i meant to put that in there too.
2.0 on custom theme.
Has custom index.template and style.css

JBlaze

Ahh, I see. I could help with 1.1.8 but I'm still shaky on custom nav bars for 2.0. Sorry :(
Jason Clemons
Former Team Member 2009 - 2012

[SiNaN]

You could just add  links/buttons in your index.template.php, template_body_above() function, above the header. I can't provide exact codes as you didn't provide details of want you want exactly and your theme.
Former SMF Core Developer | My Mods | SimplePortal

TheDisturbedOne

I've attached two images.  I misnamed them, since it isn't really a before and after.
I would like before.png to be the normal forum, and after.png to be a separate part of the site, maybe an action or a different file.

[SiNaN]

If it would be a custom page, then you can use SSI. Here is an example code:

<?php

require('path/to/SSI.php');

$context['page_title_html_safe'] = 'My Page';

$context['menu_buttons'] = array(
'home' => array(
'title' => 'Home',
'href' => 'http://someurl.com/index.php',
'show' => true,
'sub_buttons' => array(
),
),
'forum' => array(
'title' => 'Forum',
'href' => 'http://someurl.com/forum/index.php',
'show' => true,
'sub_buttons' => array(
),
),
'other' => array(
'title' => 'Other',
'href' => 'http://someurl.com/other/index.php',
'show' => true,
'sub_buttons' => array(
),
'is_last' => true,
),
);

foreach (
$context['menu_buttons'] as $id => $button)
$context['menu_buttons'][$id]['active_button'] = false;
$context['menu_buttons']['home']['active_button'] = true;

obExit(true);

function
template_main()
{
echo 'Hello! This is my custom page.';
}

?>


Set the path to SSI.php:

require('path/to/SSI.php');

Set the menu buttons with the $context['menu_buttons'] array. I'm sure you're familiar with the SMF 2.0 buttons; if not, check this topic.

Then change the body as you like:

echo 'Hello! This is my custom page.';

You can use HTML and PHP of course.

Feel free to ask if there is something unclear.
Former SMF Core Developer | My Mods | SimplePortal

TheDisturbedOne

#7
I'll try what you put there once I'm on the computer (a bit hard go code on my iPod :D)

Thanks!

TheDisturbedOne

I tried it, and this is what I got


Warning: require(public_html/atrhq.com/SSI.php) [function.require]: failed to open stream: No such file or directory in /home/disturb1/public_html/atrhq.com/fans.php on line 3

Warning: require(public_html/atrhq.com/SSI.php) [function.require]: failed to open stream: No such file or directory in /home/disturb1/public_html/atrhq.com/fans.php on line 3

Fatal error: require() [function.require]: Failed opening required 'public_html/atrhq.com/SSI.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/disturb1/public_html/atrhq.com/fans.php on line 3

http://atrhq.com/fans.php

[SiNaN]

The path to SSI.php is incorrect:

require('path/to/SSI.php');

Like I said, you've to set to suit your system. If you are not sure how to set it, use this:

require(dirname(__FILE__) . '/SSI.php');
Former SMF Core Developer | My Mods | SimplePortal

TheDisturbedOne

Ah yep, I forgot a slash in the path :X

And....it worked!!  You rock!
And btw, I use SP on my other site, and I love it :D

EDIT: one more thing, will I get in trouble since the SMF copyright isn't at the bottom?

[SiNaN]

You're welcome and thanks. ;D

About the copyright; nope. SMF copyright is not required on SSI pages.
Former SMF Core Developer | My Mods | SimplePortal

TheDisturbedOne

One more thing,
In order for me to parse BBC, would I have to call Subs.php?  And if I do, how would I call it, since it would consider it a "Hacking attempt"?

[SiNaN]

#13
You don't need to include Subs.php file, as it is included by SSI.php, by default. So you can use parse_bbc() in an SSI included page.

Also, you can include any SMF file once you include SSI.php, in case you need.
Former SMF Core Developer | My Mods | SimplePortal

TheDisturbedOne

Ok, if I understand correctly I can put:
parse_bbc([b]hi[/b]);
somewhere and it will show up right?

I'm new to this stuff, I know templates and how to do all sort of stuff with them, I'm just learning this sort of stuff right now :(

[SiNaN]

Ummm, you're close to it.

parse_bbc() will return the parsed text. So you can use it like this:

$text = '[b]hi[/b]';
$text = parse_bbc($text);
echo $text;


or

echo parse_bbc('[b]hi[/b]');

Don't forget that you have to enclose the strings with single or double quotes.(' or ")
Former SMF Core Developer | My Mods | SimplePortal

TheDisturbedOne

Ahh thanks.
Now I can finally hit *SOLVED* for the last time for this topic :D

Note to others looking to do this:  if the text uses commas, use double quotes.

[SiNaN]

You're welcome.

Quote from: TheDisturbedOne on May 17, 2009, 11:58:10 AM
Note to others looking to do this:  if the text uses commas, use double quotes.

I guess you mean single quotes ('). You can escape them using backslash (\), same goes for double quotes. Example:

echo 'Hello! I\'m not the TheDisturbed One!';

or

$text = "He said: \"We are cool!\"";
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: