phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Hilight header buttons


 
Search this topic... | Search Styles Development & Discussion... | Search Box
Register or Login to Post    Index » Styles Development & Discussion  Previous TopicPrint TopicNext Topic
Author Message
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Sun Apr 22, 2012 2:05 pm 
Post subject: Hilight header buttons

Hi
I want to make the headerbuttons change when you change page. Something like this: http://www.richnetapps.com/automatically_highlight_current_page_in/

I have done some tests with css and javascript but it just wont work. Does anybody know how to do this?
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Sun Apr 22, 2012 8:21 pm 
Post subject: Re: Hilight header buttons

The options there look interesting; being more familiar with PHP myself I'd probably choose that. It would be easier to help you if we knew which pages and menus you want to affect. One option would be to use the page names used by the Who's Online feature to identify the user's location and change your CSS/add HTML around the menu items. For more precision you may want to use $_SERVER["REQUEST_URI"] so you're not limited to those pages. Though I'm forgetting that you can't put PHP in template files, so a pure CSS/JS option might be more convenient.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Mon Apr 23, 2012 2:50 pm 
Post subject: Re: Hilight header buttons

Salvatos wrote:
It would be easier to help you if we knew which pages and menus you want to affect.

I was thinking just the main and most common buttons like index.php memberlist.php search.php profile.php.
If we figgure out one i think we can do them all? If we some how can link up the Who's Online feature and the css/ javascript.
Let me know if you figgure it out. I will continue playing with it but im not so good in php as you. icon_wink.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Apr 23, 2012 8:13 pm 
Post subject: Re: Hilight header buttons

Unfortunately I won't have time to look into code seriously for another month or so. But if you want to go the PHP way, here's what I'd probably do.

In includes/page_header.php, find
'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,

After, add a variable for your special styling. For example,
'MSEARCH_CURRENT_STYLE' => $menusearchstyle,

Of course you need to determine the value of that variable somewhere before $template->assign_vars(array(, taking into consideration the viewer's current page. Something like this will do it:
$menusearchstyle = preg_match("/search.php/", "$_SERVER[REQUEST_URI]") ? "mainmenubold" : "mainmenu";
(If the URL contains "search.php", $menusearchstyle will be the bold class, otherwise it will be the regular menu class)

Then you replace the classes for all affected menu items in templates/subSilver/overall_header.tpl:
<a href="{U_SEARCH}" class="mainmenu">
becomes
<a href="{U_SEARCH}" class="{MSEARCH_CURRENT_STYLE}">

And add the CSS according to the effects you want, for example, after:
a.mainmenu { text-decoration: none; color : {T_BODY_LINK}; }

Add
a.mainmenubold { font-weight: bold; color : {T_BODY_LINK}; }


With all these put together, your Search link should be bold when viewing the search page. Then you can expand the principle to all the links you want to change (and apply any other CSS styling you had in mind).
Sorry I don't have more time to go into details, but hopefully you'll be able to learn from this and apply it to the things you need.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Tue Apr 24, 2012 6:32 am 
Post subject: Re: Hilight header buttons

Wow this is super-awesome!! Really appretiate it. Thanks alot! Im shure i can figgure it out now thanks to you. Cant wait to get home now. icon_smile.gif
I will keep you posted!

edit:
It works great icon_smile.gif
had to change one little thing. 'MSEARCH_CURRENT_STYLE' => "$menusearchstyle" to 'MSEARCH_CURRENT_STYLE' => $menusearchstyle,
Now i only have to copy the lines and make the changes for index, memberlist aso and it is finished! Thank you for help! icon_smile.gif


edit2:
I got one small problem when multiple pages(index.php, viewforum.php, viewtopic.php etc) is using the same button/ class(forums). I tried to add more to one variable and one for every but its not working yet. I will try more later tonight!
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Wed Aug 01, 2012 2:01 pm 
Post subject: Re: Hilight header buttons

I read somewhere that multiple filenames have to be in an array when using preg_match. Do you know how to do that?
So viewforum.php and viewtopic.php uses same button style.
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Wed Aug 01, 2012 5:52 pm 
Post subject: Re: Hilight header buttons

If you put multiple pages in preg_match, it will only validate if all pages are true (i.e. if your user is viewing all these pages at once). So I don't think that's really an option for what you're trying to do icon_wink.gif
Why not just set them one by one?
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Wed Aug 01, 2012 10:11 pm 
Post subject: Re: Hilight header buttons

I am doing something wrong. When i have just index.php it works. When i add the viewforum.php that starts to work but then the index.php stops working again.

in the overall_header.tpl i have this:
Code:
<li><a href="index.php" class="{MINDEX_CURRENT_STYLE}">Forum</a></li>


in page_header.php i have this:
Quote:
'MINDEX_CURRENT_STYLE' => $menuindexstyle,


and this:
Code:
$menuindexstyle = preg_match("/index.php/", "$_SERVER[REQUEST_URI]") ? "button1active" : "button1";
$menuindexstyle = preg_match("/viewforum.php/", "$_SERVER[REQUEST_URI]") ? "button1active" : "button1";



i have also tried doing like this:
Code:
'MINDEX_CURRENT_STYLE' => $menuindexstyle,
'MINDEX_CURRENT_STYLE' => $menuindexstyle2,


and so:
Code:
$menuindexstyle = preg_match("/index.php/", "$_SERVER[REQUEST_URI]") ? "button1active" : "button1";
$menuindexstyle2 = preg_match("/viewforum.php/", "$_SERVER[REQUEST_URI]") ? "button1active" : "button1";
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Thu Aug 02, 2012 6:32 am 
Post subject: Re: Hilight header buttons

Oh, I see icon_smile.gif You need a different variable for each link, otherwise you're just resetting that one variable's value to your latest change. So it should look a little more like:

Code:
<li><a href="index.php" class="{MINDEX_CURRENT_STYLE}">Forum</a></li>
<li><a href="viewforum.php" class="{MVIEWFORUM_CURRENT_STYLE}">View Forum</a></li>


Code:
$menuindexstyle = preg_match("/index.php/", "$_SERVER[REQUEST_URI]") ? "button1active" : "button1";
$menuviewforumstyle = preg_match("/viewforum.php/", "$_SERVER[REQUEST_URI]") ? "button1active" : "button1";


Code:
'MINDEX_CURRENT_STYLE' => $menuindexstyle,
'MVIEWFORUM_CURRENT_STYLE' => $menuviewforumstyle,


Of course you can rename the variables to (mostly) whatever you like, admittedly the ones I originally suggested look very cluttered.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Thu Aug 02, 2012 7:48 am 
Post subject: Re: Hilight header buttons

Okey thanks. Yes that works fine. icon_smile.gif Im sorry im so bad to explain. icon_redface.gif But i want to have only one button. So the same button lights up when the user is on index.php, viewforum.php, viewtopic.php and all other related to the forums.

I also get the same issue in the gallery. There are multiple pages that needs to trigger the same button.
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Thu Aug 02, 2012 5:05 pm 
Post subject: Re: Hilight header buttons

Oh, okay! Then you indeed want a single variable for this one button. The difference will be how we decide to trigger it:


Code:
if ( preg_match("/index.php/", "$_SERVER[REQUEST_URI]") || preg_match("/viewforum.php/", "$_SERVER[REQUEST_URI]") || preg_match("/someotherpage.php/", "$_SERVER[REQUEST_URI]") )
{
$menuindexstyle = "button1active";
}
else
{
$menuindexstyle =  "button1";
}


|| acts as OR, so we're essentially checking "If the URL contains this, or this, or this...". Simply add all the pages you want to check to the first line using the same syntax and you should be good to go icon_smile.gif
Please excuse the lack of indentation, I'm a bit short on time.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Thu Aug 02, 2012 8:32 pm 
Post subject: Re: Hilight header buttons

YESYES!! That solved it. You are awesome!! Thanks! icon_biggrin.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » Styles Development & Discussion  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0244 seconds using 15 queries. (SQL 0.0062 Parse 0.0006 Other 0.0176)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo