Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION How to add subtitles to menu?
#1
I'm converting my website to Get-Simple, and I'm stuck at adding subtitles to the menu. Please take a look at the images below:

What I want:
[Image: reXr6O0.png]

How it is now:
[Image: zpEYvDh.png]

I've researched a lot so far, and here's what I tried:

I have downloaded i18N and i18N navitagion plugins, I've added a custom component called menu_custom

menu_custom (component)
PHP Code:
<li class="<?php echo $item->classes; ?>">
  <
a href="<?php echo htmlspecialchars($item->link); ?>">
    <?
php echo htmlspecialchars($item->text); ?>
    <span class="subtitle"><?php echo htmlspecialchars($item->subtitle); ?></span>
  </a>
  <?php if ($item->isOpen) { ?>
    <ul><?php $item->outputChildren(); ?></ul>
  <?php ?>
</li> 

template.php
PHP Code:
<ul id="nav">
    <?
php get_i18n_navigation($slug$minlevel=0$maxlevel=0$show=I18N_SHOW_NORMAL$component=menu_custom?>
</ul> 

The problem is, how can I assign the $item->subtitle to each menu? Also, is there another/easier way to do this?

Thanks!
Reply
#2
Did it.

Added custom fields using i18N Custom Fields plugin, here's what I've done, in case someone looks for this in the future:

1 - Everything I mentioned in the first post
2 - Added i18N Custom Fields Plugin
3 - Created a custom field named subtitle
4 - Filled it with the text I wanted in the page

That's it.
Reply
#3
Thats what I use, custom fields.
3.4 will have an alternate title and summary field for using for these kinds of design patterns, subtitles, taglines etc., i use them alot.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#4
(2014-07-12, 00:15:58)lukinhasb Wrote: template.php
PHP Code:
<ul id="nav">
    <?
php get_i18n_navigation($slug$minlevel=0$maxlevel=0$show=I18N_SHOW_NORMAL$component=menu_custom?>
</ul> 

Most likely you want to use:
PHP Code:
<ul id="nav">
    <?
php get_i18n_navigation($slug00I18N_SHOW_NORMAL'menu_custom');?>
</ul> 
Besides saving some keystrokes, this will avoid setting probably undesired global variables.
Reply
#5
It doesn't work for me. Can you tell us please what code exactly in each file we have to add or change to get working menu subtitles. Thanks.
Reply
#6
Just to unpack what was said above:
  • Download the I18N Custom Fields Plugin
  • Use it to create a field with the name 'subtitle'
  • For each page that you want to have a subtitle, edit the page and give  it a value for the newly created 'subtitle' field
  • Create a component (in Theme -> Components) for your menu called 'menu_custom' with the following code:
PHP Code:
<li class="<?php echo $item->classes; ?>">
 <a href="<?php echo htmlspecialchars($item->link); ?>">
   <!--title-->
   <?php echo htmlspecialchars($item->text); ?>
   <!--subtitle-->
   <span class="subtitle"><?php echo htmlspecialchars($item->subtitle); ?></span>
 </a>
 <?php if ($item->isOpen) { ?>
   <ul><?php $item->outputChildren(); ?></ul>
 <?php ?>
</li> 
  • Whilst in Theme, edit the template for your active theme. Where your menu is supposed to be rendered (e.g. in the header template in header.inc.php or whichever template file has your navigation), replace the call to get_navigation() with:
PHP Code:
// Get the current page id
$slug get_page_slug();

// Render the custom navigation with component 'menu_custom'
get_i18n_navigation($slug00I18N_SHOW_NORMAL'menu_custom'); 
Reply




Users browsing this thread: 1 Guest(s)