SOLVED Main Links Set To Current Style


Subject: Main Links Set To Current Style
Hi

I am making a template for icy2.0 and am trying to achieve so that when a user is on a page the link will highlight through css showing the user they are on that page.

As icy is nearly alike to phpbb3 I was reading through their template vars.

in icy the code I need is already installed in default.cfg

Code: [Download] [Hide] [Select]
'SCRIPT_NAME' => str_replace('.' . PHP_EXT, '', $user->data['page']['page_name']),


and then by placing tags and code in overall_header.tpl for example

Code: [Download] [Hide] [Select]
<!-- IF SCRIPT_NAME eq 'index' -->
<li><a href="#url" id="current">Forum</a></li>
<!-- ELSE -->
<li><a href="#url" >Forum</a></li>
<!-- ENDIF -->


then using id=current in the css file should by rights show the page as highlighted, but sadly it does not.


As the coding in icy is all new to be compared to older versions anyone possibly have any ideas if this will work or if I have an error somewhere.

Any help would greatly be appreciated and if I get this working I will post a walk through for anyone else who ight need it.

:mrgreen: :mrgreen:

Subject: Re: Main Links Set To Current Style
The variable $breadcrumbs['address'] contains the link for the current page.

If you grep for: grep -rn "$breadcrumbs\['address'\]" * you'll find it's used in pretty much every page.

Inside a template it's the 'BREADCRUMBS_ADDRESS' variable.

HTH

John

Profile PM  
Subject: Re: Main Links Set To Current Style
Thanks for the tip John

I couldnt see that for looking, new there was a navigation style in icy but totally forgot about the breadcrumbs.

Thanks

Mike

:mrgreen: :mrgreen:

extra comments

I have just had a look at the breadcrumbs which would work ideally but I dont believe they will with what I am trying to do.

I need the links to appear in overall header like the image below...

main_liks

I have a few custom pages using cms pages and I thought there might be an easy way to show the current page using present code...

the breadcrumb system would work if I needed to show the current page without any other links but I need the other links to show too.

as I said if this was standard pages in icy then I wouldnt have a problem, it is the cms custom pages that I cannot make it work on.


thanks for your help

:mrgreen: :mrgreen:

Subject: Re: Main Links Set To Current Style
This should give you something to mess with,. Just drop it all into overall_header.tpl and have a "PLAY"? :mryellow:

The Script:

Code: [Download] [Hide] [Select]
<div id="stylemenu">
<ul>
<?php if (basename($_SERVER['SCRIPT_NAME'], '.' . PHP_EXT) == 'index'){ ?>
<li><a href="index.php" class="current">Home</a></li>
<?php }else{ ?>
<li><a href="index.php">Home</a></li>
<?php } if (basename($_SERVER['SCRIPT_NAME'], '.' . PHP_EXT) == 'forum'){ ?>
<li><a href="forum.php" class="current">Forum</a></li>
<?php }else{ ?>
<li><a href="forum.php">Forum</a></li>


<?php } ?>

<!-- AND SO ON -->

<li><a href="new.php">New</a></li>
<li><a href="profile.php">Profile</a></li>
<li><a href="search.php">Search</a></li>
<li><a href="faq.php">FAQ</a></li>
</ul>
</div>


The CSS:

Code: [Download] [Hide] [Select]
<style type="text/css">
#stylemenu{ position: absolute; top: 0; right: 10px; margin: 0px 0px 0px 0px; display:block;font-size:13px;font-weight:bold;background:transparent;font-family:Arial,Verdana,Helvitica,sans-serif;}
#stylemenu ul{margin:0;padding:0;list-style-type:none;width:auto;}
#stylemenu ul li{ display:block;float:left;margin:0px; padding-left:10px; }
#stylemenu ul li a{
display:block;
float:left;
color:#ff0000;
text-decoration:none;
padding-left:15px;
padding-right:15px;
padding-top:10px;
padding-bottom:5px;
height:20px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}

#stylemenu ul li a:hover,#stylemenu ul li a.current{color:#fff; background: #0000ff;}

</style>

Profile PM  
Subject: Re: Main Links Set To Current Style
Thank you Mort

Works like a charm

:mrgreen: :mrgreen:

Subject: Re: Main Links Set To Current Style
You're welcome. ;)

If you are actually using the CSS you can drop this from it (if you haven't already done it?

position: absolute; top: 0; right: 10px;

and use this to slot it in wherever you want it etc. :mryellow:

Code: [Download] [Hide] [Select]
<tr>
<td>
<div id="stylemenu">

BLAH!

</div>
</td>
</tr>

Profile PM  
Subject: Re: [SOLVED] Main Links Set To Current Style
It was a bug... please change it like this:

Code: [Download] [Hide] [Select]
'SCRIPT_NAME' => str_replace('.' . PHP_EXT, '', $user->page['page_name']),

Subject: Re: [SOLVED] Main Links Set To Current Style
Thanks Luca

Spent ages trying to make it work using your code and nearly gave up.

:)

code changed works as it should.

:mrgreen: :mrgreen:

Subject: Re: [SOLVED] Main Links Set To Current Style
DWho wrote: [View Post]
code changed works as it should.

:mrgreen: :mrgreen:


HA! So now you have two ways of doing it.

One for php (Change the CONSTANT), and one solely for phpBB (Icy Phoenix).

:mryellow: :twisted:

Profile PM  
Subject: Re: [SOLVED] Main Links Set To Current Style
My thoughts exactly.. :mryellow: :mryellow:

Subject: Re: [SOLVED] Main Links Set To Current Style
mort wrote: [View Post]
One for php (Change the CONSTANT), and one solely for phpBB (Icy Phoenix).

:mryellow: :twisted:

If you want your solution to be fully independent from phpBB (Icy Phoenix) you should remove the constant PHP_EXT and use 'php' instead. :P

Subject: Re: [SOLVED] Main Links Set To Current Style
Update: Informpro made this for me: put it in your CFG file:

Code: [Download] [Hide]
  1. $page = explode('/', $_SERVER['SCRIPT_NAME']); 
  2. $page = substr(end($page), 0, -4); 
  3. if ($page == 'index') { $images['current'] = 'current'; } 
  4. if ($page == 'blog') { $images['current'] = 'current'; } 
  5. if ($page == 'about us') { $images['current'] = 'current'; } 
  6. if ($page == 'contact us') { $images['current'] = 'current'; } 
  7. if ($page == 'package') { $images['current'] = 'current'; } 
  8. if ($page == 'login') { $images['current'] = 'current'; } 


In your header, you simply will have to add {current} inside the class, such as:
Code: [Download] [Hide]
  1. <a href="index.php" class="{current}">Home</a> 
  2. <a href="forum.php" class="{current}">Forum</a> 
  3. <a href="blog.php" class="{current}">Blog</a> 

Well, if there aren't any other classe to define you can even get some space by using this, I guess:
Code: [Download] [Hide]
  1. if ($page == 'index') { $images['current'] = 'class="current"'; } 
Code: [Download] [Hide]
  1. <a href="index.php" {current}>Home</a> 


and define your class in the css, for example:
Code: [Download] [Hide]
  1. .current {background-color:blue} 


Obviously, this require you to set up the array for the $image['current'] variable but you can use it to define it automatically:
Code: [Download] [Hide]
  1. foreach ($images as $k => $v) 
  2. $template->assign_var(strtoupper($k), $v); 


Well, that's all some tips from Informpro, I'm just sharing. Hope this help.


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 7.1083s (PHP: 0% SQL: 100%)
SQL queries: 31 - Debug Off - GZIP Enabled