Hi I'm using Silverstripe CMS on the "Simple" template. I'm wondering how to create subtitles for the menu items.
The current navigation template is like so:
<nav class="primary">
<span class="nav-open-button">²</span>
<ul>
<% loop $Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle.XML</a></li>
<% end_loop %>
</ul>
I'm thinking i could somehow edit $Menutitle.XML
but how? Also the sub title should be displayed directly under the Title but as the same button. The SubTitle would need to have a different css rule so that it could be smaller. I know that the CMS has an area for me to edit the page titles which become the menu titles, would it be easy to add a subtitle to the admin like that or is there some other easier way? I only need to make a few of them.
easy thing to do:
add a field to the $db
array of your Page
class:
private static $db = array('SubTitle' => 'Varchar(255)');
then add this field in the getCMSFields
method in the same file:
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', TextField::create('SubTitle'));
return $fields;
}
now you can use the variable $SubTitle
in your template like so, for example:
<li class="$LinkingMode"><a href="$Link" title="$Title.XML">$MenuTitle.XML - $SubTitle</a></li>
in case all of this sounds too complex, you should really run through the silverstripe tutorials first, see http://doc.silverstripe.org/framework/en/tutorials/