Icy Phoenix

     
 

SOLVED Main Links Set To Current Style

SOLVED Main Links Set To Current Style

Article
Reply with quote    Download Post  
Post 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.

   



 
DWho - View user's profile Send private message  
DWho [ Thu 09 Aug, 2012 17:02 ]
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us


SOLVED Main Links Set To Current Style

Comments
Reply with quote    Download Post  
Post 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



 
jhl - View user's profile Send private message  
jhl [ Thu 09 Aug, 2012 19:31 ]
Reply with quote    Download Post  
Post 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

   

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

   



 
DWho - View user's profile Send private message  
DWho [ Fri 10 Aug, 2012 13:23 ]
Reply with quote    Download Post  
Post 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"?

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>




 
mort - View user's profile Send private message  
mort [ Sat 11 Aug, 2012 05:25 ]
Reply with quote    Download Post  
Post Re: Main Links Set To Current Style 
 
Thank you Mort

Works like a charm

   



 
DWho - View user's profile Send private message  
DWho [ Sun 12 Aug, 2012 12:56 ]
Reply with quote    Download Post  
Post 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.  

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

BLAH!

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




 
mort - View user's profile Send private message  
mort [ Sun 12 Aug, 2012 13:12 ]
Reply with quote    Download Post  
Post 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']),




 
Mighty Gorgon - View user's profile Send private message  
Mighty Gorgon [ Tue 14 Aug, 2012 19:55 ]
Reply with quote    Download Post  
Post 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.

   



 
DWho - View user's profile Send private message  
DWho [ Wed 15 Aug, 2012 11:27 ]
Reply with quote    Download Post  
Post Re: [SOLVED] Main Links Set To Current Style 
 
DWho wrote: [View Post]
code changed works as it should.

   


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

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

   



 
mort - View user's profile Send private message  
mort [ Sat 18 Aug, 2012 07:38 ]
Reply with quote    Download Post  
Post Re: [SOLVED] Main Links Set To Current Style 
 
My thoughts exactly..    



 
DWho - View user's profile Send private message  
DWho [ Sat 18 Aug, 2012 15:23 ]
Reply with quote    Download Post  
Post 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).

   

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



 
Mighty Gorgon - View user's profile Send private message  
Mighty Gorgon [ Sun 26 Aug, 2012 11:00 ]
Reply with quote    Download Post  
Post 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.



 
Yros - View user's profile Send private message  
Yros [ Fri 12 Oct, 2012 14:32 ]
Display posts from previous:    

HideWas this topic useful?

Post new topic  Reply to topic  Page 1 of 1
 
 




 


 

  cron