Hello,
Im custimising a theme. The index.template.php file for the special theme.
I've added some buttons, working good.
Example:
echo '
<li ' , $current_action=='forum' ? ' class="chosen"' : '' , '><a href="', $scripturl, '?action=forum">Forum<span>Forumet</span></a>';
But now i want to add a page, not a action. How do i do that. I'm kinda noob so xD
I we're trying like:
echo '
<li ' , $current_page=='forum' ? ' class="chosen"' : '' , '><a href="', $scripturl, '?page=forum">Forum<span>Forumet</span></a>';
As you can se i replaced action with page. Can't get it to work, and no, im not trying to link to forum, im trying to link to a special map in my www directory.
Example:
mywebsite.com/directory
I'm trying to link it to the directory
Thanks!
/Molo
Hi, what version SMF is that for? It looks like a 1.x theme. ???
Have you created that page yet? If so and it's outside of the SMF directory, remove the $scripturl variable and hard code in the full link.
echo '
<li ' , $current_page=='directory' ? ' class="chosen"' : '' , '><a href="http://mywebsite.com/directory"><span>Directory</span></a>';
Thanks!
The code works good :)
Im using 2.0.2, latest. Didn't complain when i installed the theme so i guess it's good.
But, new problem, i want it to open in the same window like the forum do etc :)
Thanks for helping me :)
/Molo
For 2.x, the menu is now an array in Subs.php and that's what's typically used the show the menu on most themes now. But whatever works. :)
For that add target="_blank"
echo '
<li ' , $current_page=='directory' ? ' class="chosen"' : '' , '><a href="http://mywebsite.com/directory" target="_blank"><span>Directory</span></a>';
That didnt seem to work, still opening in a new tab :/
I'm not sure but i think it has something with <iframe src
to do.
It could be but I don't have any experience in that area to answer correctly.
But normally, target="_blank" should open a link in a new window. ???
No, i don't want it in a new window, i want it to in the same tab, same window, but like Forum do, like Home do.
Same window, but like minimized in the middle, idk if you understand :/
Sorry, missread. This page contains the options. See which one works.
http://www.w3schools.com/TAgs/att_a_target.asp
I got i working, idk how really, did something with Dreamportal.
But now I want to make the button marked when it's pressed, like the others.
This one is working: It's a action, as normal with SMF.
if (in_array($context['current_action'], array('moderate', 'admin')))
$current_action = 'moderate';
But, my new one, is a page, how to i make it work? :/
if (in_array($context['current_page'], array('bans')))
$current_page = 'bans';
In what I first posted it was checking $current_page to mark that tab as active.
So if that's the case, this should work. (change the "xxx" to the name of that page)
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'xxx')
$current_page = 'directory';
Hello
If my page is mywebsite.com/index.php?page=bans
Then i should replace xxx with bans?
Like this?
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'bans')
$current_page = 'directory';
If so, it doesn't work :/
Managed to get it working, but it also marks the Home page, any fix?
What did you do to get it working?
For each link, the "$current_page==" value needs to be unique.
echo '
<li ' , $current_page=='walla' ? ' class="chosen"' : '' , '><a href="http://193.11.112.174/index.php?page=bans" target="">Bans<span>Server bans</span></a>';
That's the button
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'bans')
$current_page = 'walla';
That's the marking stuff, that makes the button marked. In the beginning i didn't se same $current_page, my bad.
But it's still marking both Home and Bans, i only wan't Bans marked.
The "Home" button. Is that using $current_page or $current_action. It should be the same for all tabs.
Quote from: Kays on September 17, 2012, 02:08:53 PM
The "Home" button. Is that using $current_page or $current_action. It should be the same for all tabs.
$current_action = 'home';
That's the home button mark thing.
If I remove that the home button never get's marked. But, i want it marked if it's pressed xD
echo '
<li ' , $current_action=='home' ? ' class="chosen"' : '' , '><a href="', $scripturl, '">Hem<span>Förstasidan</span></a>';
That's the homebutton button.
That's the problem. The home button is checking for $current_action while your button is checking for $current_page.
In the code for your button and the check, change $current_page to $current_action.
It's working!
Thank you so much! :)
To others:
My button, the one you press:
echo '
<li ' , $current_action=='walla' ? ' class="chosen"' : '' , '><a href="http://mywebsite.com/index.php?page=bans" target="">Bans<span>Server bans</span></a>';
And the one that marks the button:
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'bans')
$current_action = 'walla';
Once again, Thanks!
/Molo
Great. :)