Current Page Item

44 views
Skip to first unread message

rustless

unread,
Jun 12, 2012, 12:28:16 PM6/12/12
to habari-users
Hi! I'am creating theme for Habari, this is navigation:

<ul class="topmenu">
<li class="home current-menu-item"><a href="<?php
Site::out_url( 'habari' ); ?>"><span>Home</span></a></li>
</ul>

There are li class "home current-menu-item", but when user on
nonhomepage, I want li class to be simply "home". How to do it?
Thanks!!!

rustless

unread,
Jun 12, 2012, 4:33:22 PM6/12/12
to habari...@googlegroups.com
OK, I done this with one:

<li class="home<?php if ( $request->display_home ) : echo ' current-menu-item'; endif; ?>"><a href="<?php Site::out_url( 'habari' ); ?>"><span>Home</span></a></li>

But what I should do with pages? Help, please... (sorry for my English)

вторник, 12 июня 2012 г., 20:28:16 UTC+4 пользователь rustless написал:

Colin

unread,
Jun 13, 2012, 5:10:09 AM6/13/12
to habari...@googlegroups.com
Something like the following should have the desired effect (this is butchered code from one of my themes - I've not tested it in this form):

---
<?php foreach ( $pages as $page ) : ?>
<li class="menu-item <?php echo ( isset( $post ) && $page->id == $post->id ) ? 'current-menu-item' : '' ?>"><a href="<?php echo $page->permalink; ?>"><?php echo $page->title; ?></a></li>
<?php endforeach; ?>
---

$pages is defined in my theme.php as follows:

---
public function add_template_vars()
{
if ( !$this->template_engine->assigned( 'pages' ) ) {
                $this->assign('pages', Posts::get( 'page_list' ) );
        }
[... the rest of the function's contents here ... ]
}
---

HTH
Colin


--
To post to this group, send email to habari...@googlegroups.com
To unsubscribe from this group, send email to habari-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/habari-users



--
Colin Seymour
Blog: http://colinseymour.co.uk
Tech Stuff: http://lildude.co.uk
Barefoot Running: http://barefootrunner.co.uk
IRC: lildude #habari
Reply all
Reply to author
Forward
0 new messages